When using :%s/foo/bar/c to replace foo with bar, but with the c tag to have a yes or no dialog for each replace, I have really unreadable highlighting. All occurences of the searched word appear in grey background with white text (normal search highlight). However the one occurence I'm asked for is "highlighted" in yellow text without background => easily confused with regular text.
I found a million highlight search coloring things, but nothing to this one subsitute entry you are asked for. How do I change only this one? Thanks for any hint.
It's IncSearch.
From :h hl-IncSearch :
*hl-IncSearch*
IncSearch 'incsearch' highlighting; also used for the text replaced with
":s///c"
Related
For more comfortable work with YAML/Ansible I wanna highlight pairs of spaces with different colors in a row.
For example where we write " - name" (six spaces here in the beginning of string) first pair of spaces will be yellow, next two will be red and so on.
But I can't understand how to write it in my .vimrc. Someone can help?
These aren’t exactly the two-space highlighting your looking for, but vim-indent-guides and indentLine both can get you the essential feature of highlighting columns of indent.
The alternative I think would be to create n match groups where group i matches 2 spaces (after the first 2(i-1) spaces), and then color those differently.
Basically, The background behind the line numbers are darker than the background behind the code, as you can see from the picture below. The background behind the codes has a slightly lighter color than that behind the line numbers. I hope I describe this well enough for you to understand.
I am just wondering what code should I write onto .vimrc file in order to capture the same effect ?
You will need to put the command highlight in your .vimrc followed by certain arguments. To learn about the arguments that highlight takes, type :help :highlight and press Return. This will open the help for the highlight command.
This is the particular format of highlight that you want:
:hi[ghlight] [default] {group-name} {key}={arg} ..
Add a highlight group, or change the highlighting for
an existing group.
See |highlight-args| for the {key}={arg} arguments.
See |:highlight-default| for the optional [default]
argument.
You can find the correct {group-name} to use with :help highlight-groups. As romainl said, the group names for the line numbers at the left are LineNr and CursorLineNr.
And what to put for the {key}={arg} arguments? Well, check :help highlight-args as the help text suggested. The key represents what aspect of the text should be changed (e.g. italic or not, or the foreground color), and the arg represents what it should be changed to (e.g. italic, or bright red). In your case, you want to change the background color, which is controlled by ctermbg for terminals and guibg for GUIs.
Run :highlight Normal to learn the background color you want. You should see something like guibg=grey10. So try setting the guibg (background color in the GUI) of your line numbers to the color grey10 in your .vimrc:
highlight LineNr guibg=grey10
highlight CursorLineNr guibg=grey10
Edit
It sounds like you want to change the code background color, not the line number background color. To do that, write the same command, but use the highlight group that represents normal code instead of the LineNr and CursorLineNr highlight groups that represent line numbers. If you look at highlight-groups help, you can see that the highlight group for code in general is called Normal. So write
highlight Normal guibg=grey
, changing grey to whatever color you want.
If you aren’t sure what color you want, and you just know that you want it to be the same as some other color, run :highlight {group-name} to look up the settings for that group name, and look for the background color key within it. For example, if you want to make the code background color the same as the line number background color, run :highlight LineNr. You will see something like guibg=#242424, which would mean to use #242424 as the color.
You can find LineNr and CursorLineNr listed under :help highlight-groups.
You will need to add/change the corresponding lines in your colorscheme.
I am checking a log file using vim. There's only one word can be highlighted, when I search another word,the second word is highlighted but the previous one is not highlighted anymore.
Can anyone show me a way that easily highlight/cancel highlight multiple words in vim? For example, I want to highlight words "stack", "over" and "flow", then I want to cancel the highlight of "stack" and highlight another word "error". So that I can analyze the log more efficiently.
Thanks.
There are two simple ways to highlight multiple words in vim editor.
Go to search mode i.e. type '/' and then type \v followed by the words you want to search separated by '|' (pipe).
Ex: /\vword1|word2|word3
Go to search mode and type the words you want to search separated by '\|'.
Ex: /word1\|word2\|word3
Basically the first way puts you in the regular expression mode so that you do not need to put any extra back slashes before every pipe or other delimiters used for searching.
/\v\/folder|\/copy - search for \folder and \copy
and add to .vimrc set hlsearch
To have all words highlighted in the same color and be able to search and replace all of then, add them as alternatives to the search pattern, e.g. /foo\|bar. My SearchAlternatives plugin provides handy mappings to add and remove patterns.
If you want different colors for different matches, you need a highlight mechanism different from the built-in search. My Mark plugin is used by many people for that. (The plugin page has links to alternative plugins.)
How can I highlight tabs with one color and spaces with another in vim ?
I know how to highlight only tabs or only spaces. And I don't know how to select the colors separately for both spaces and tabs.
A simple solution would be to do something like:
:match Error /\t/
:2match Todo / /
Where Error and Todo are highlight groups from :highlight. This is going to take up two of your three matches and will only be temporary.
Theoretically you could use matchadd() or a combination of highlight groups and :syntax match commands in your .vimrc to make this more permanent but your question doesn't really specify if that's what you want.
I need to highlight anything beyond column 72 with a different background color. What's the best method? Something similar to a visible line margin that some editors do is also good. Is it possible?
Some background:
The syntax is a Pascal like, and works correctly.
Only the Background needs to change. The foreground is already highlighted as it should be. There are cases where a String will be more than 80 characters and will pass the 72 column limit, and should be highlighted as a string.
The coding standards are similar to COBOL and all characters beyond column 72 should by comment lines. These column 72 comments do start with the comment start character, and are highlighted properly.
You can
:match DiffAdd '\%>72v.*'
which will highlight the characters you don't want.
(adapted from here).
You can try this:
:setlocal colorcolumn=72
That'll just highlight the whole column. Use set instead of setlocal if you want it to apply to all tabs/splits.
Check out the help file for more details.