when try to work with vim I installed several plugins and started trying to write some java code and during coding found such an annoying space highlights
dont know what is that and how to turn it off
I don't know which plugins you installed, but I'm sure that - although annoying to you - these highlighted areas are pretty useful. (1) You seem to be mixing spaces and tabs for indentation and (2) you have trailing whitespace on some lines. These "problems" are highlighted in some warning color.
First of all it's a very good idea to apply a consistent coding style. This includes using either tabs or spaces for indentation. Just place the cursor on the yellow area and compare the whitespace with those lines without yellow background (move the cursor left or right). There is plenty of documentation about indentation, including the relevant vim settings (e. g. here or here).
The second thing is that apparently the syntax highlighting plugin "complains" about whitespace at the end of a line. You should also avoid that. You could remove trailing whitespace automatically when saving the buffer (see here).
Related
I would like to get Vim to stop highlighting list characters (-,*) and heading characters (#) in rmarkdown. You can find a screenshot here: https://imgur.com/a/0YSB8V8.
This is happening when I set the file type to either pandoc or rmd. This is also happening no matter what terminal or colortheme I use.
I have the plugins: vim-pandoc, vim-pandoc-syntax, and vim-rmarkdown installed.
I would like to know a way to make the two characters just appear normally.
I would also like to know if there is a way to make italicized text in tables and headings appear italicized. As far as modifying the appearance of italicized text, I've tried using: hi Italic ctermfg=red cterm=italic in my vimrc, but that does not seem to affect the text in between asterisks (*) in rmd files. I admit I don't know much about the way that syntax works in Vim. Do I need to modify after/ftplugin/rmd.vim or runtime/syntax/rmd.vim? What is the difference between the two?
Any help would be appreciated!
Your syntax highlighter does not seem to recognize the bullet points, but thinks that they mark the beginning of an italic span. Maybe you have a clash of plugins. You could also try another highlighter (e.g. vim-polyglot, supports italics).
vim-pandoc-syntax uses the conceal feature (:h conceal). You can recolor the highlighting group Conceal to change the appearance of the replacement characters.
You can put changes to existing syntax files in .vim/after/syntax/rmd.vim. Files in syntax are executed when they are needed for the first time, but at most once per session. Files in ftplugin are executed every time the file type is changed.
I just added the indentLine plugin for Vim, and I love it apart from this annoying syntax highlighting issue where the background of the dividing character stays black while the rest of the line is highlighted. It's really distracting for me. How can I fix this and make the background the same as the rest of the line, and the dividing character still visible?
If I write an if statement in my C program, press enter three times, then write a comment, the below is my output. Notice the two lines between the condition and the comment are completely empty.
if(my_condition) {
<Tab>// My comment here
My issue is that Vim does not insert any tab character(s) between the beginning of the line and the cursor position until a character is typed. This is very annoying for me, because I like to move my cursor up and down the block of code often. Since there isn't a real tab on the two lines, if I moved up one line my cursor would go to the beginning of the line, instead of staying on the same column. I come from Sublime Text and other editors where this has never been a problem.
Is there a plugin or setting such that I can accomplish the following?
if(my_condition) {
<Tab>
<Tab>
<Tab>// My comment here
All help is appreciated. I've looked into using Visual mode, but have had undesirable side effects of enabling it all the time. Certainly there is a simple way to automatically add the tabs when I make a new line?
This is very annoying for me, because I like to move my cursor up and down the block of code often.
Well, as you might have noticed, switching to vim means that you need to change your own editing behavior. And that might be the toughest, more than learning the new commands, because habits die hard!
I'm not saying that you should stop scrolling around your function in an useless manner, though, but that you should stop moving around with the "cursor" keys in insert mode.
When you're doing movements when in insert mode it has the side effect you're exposing as "inconvenient", but it also has the side effect of breaking the "repeat" command (.). After a cursor movement in insert mode, a . will only repeat characters typed after that movement.
So, what you should consider in your editing behavior, is to avoid empty lines, avoid trailing spaces/tabs and never move around in insert mode. Insert mode is for insertion, and the normal mode is for moving around and doing actions on the text.
There are a lot of move commands you can abuse in normal mode (j/k, <C-e>/<C-y>, {/}, …).
That being said, if you get yourself in a situation where you've fscked the indentation, you might want to keep on editing, not caring about the indent, and once you're back in normal mode issue a =i{ that will indent everything within the block following the syntax file (and your indent settings).
In both Eclipse and Notepad++, I have my text editors configured so a space has a semi-transparent dot in the center, which makes it easy to count whitespace. I prefer to use spaces instead of tabs in my text editing, and this feature is crucial when working with a whitespace-sensitive language like Python.
I have attached a screenshot with some dummy code in case my wording wasn't clear.
At any rate, is there any way to come close to this functionality in Vim (or GVim)? I suppose there is highlighting but that does seem a bit subpar. There's also good old fashioned math by looking at the column number. What are my other options?
Thes lines in your vimrc should give you an approximation but you won't get dots for normal or leading space: only trailing spaces. That's a Vim limitation.
set list
set listchars=
set listchars+=tab:»\
set listchars+=extends:›
set listchars+=precedes:‹
set listchars+=nbsp:·
set listchars+=trail:·
See :help 'list' and :help 'listchars.
I agree with romainl's answer, but would like to add a mention of the indent guides, which can colour indentation based on your current tab size settings.
I've used the Windows version of Vim in the past, but am
new to MacVim. In MacVim, when I switch to visual mode, use the $
motion (highlighting from my cursor to the end of the line), and yank,
when I paste the copied content, it includes the carriage return,
bumping everything after the paste point down to a new line.
This behavior seemed unfamiliar (not to mention annoying) to me. Is there any way to change this behavior to match the Windows version, where the newline is not included in the yank?
Is just copying the text until the end of the line inappropriate? y$ will just copy from your current cursor until the end of the line, without the newline.
There's a little-known motion that serves this need regardless of configuring Windows behaviors and can generally be useful in other contexts: g_. Quoth :help g_:
g_ To the last non-blank character of the line and
[count - 1] lines downward |inclusive|. {not in Vi}
Personally I don't tend to use this for yanking because I avoid the extra visual mode keystroke and use y$ (which doesn't copy the newline, as #zigdon suggested). Or better yet, nnoremap Y y$ so that Y works consistently with C and D.
I do however often use g_ with surround.vim where the mappings to add surrounds are often harder to remember for me than using visual selection. If you want to select until the end of the line and surround with parens, for instance, it would be ys$), which isn't bad but I tend to forget the ys mnemonic. v$S) seems natural but has the same problem as your question: it includes the newline, and that's a total mess when adding surrounds. vg_S) is exactly what you usually want.
One nice thing about doing it visually is that you can correct mid-selection: I still tend to hit v$ by muscle memory a lot, but if you see that you've overshot before acting, you can still hit g_ and fix the selection.
You may try Du. Effectively it does exactly what you want and it is more finger-friendly if you intend to use it in raw editing.
I discovered that the option that was causing the behavior I'm used to seeing is behave mswin, which I believe is on by default in GVim for Windows.