Questions tagged [highlight]

Adding highlighting to the document other than syntax highlighting (such as hlsearch or :match)

52
votes
7answers
41k views

How can I clear word highlighting in the current document (e.g. such as after searching for a word)?

When you search for a word in a file with something like /console.log, all of the instances of console.log are highlighted. When you're no longer interested in these, the highlighting can be ...
19
votes
3answers
8k views

Can the split separator in vim be less than a full column wide?

I use a tiling window manager (awesome) + a terminal multiplexer (tmux) + splits inside of vim. I have no window decorations at all, so you there is no visual split between them at all if the content ...
19
votes
5answers
3k views

Set cursor colour different when on a highlighted word

With the current colourscheme I have been using, it is hard to find where the cursor is positioned when navigating through search results. The highlighting colour and the cursor colour are blending in ...
16
votes
4answers
10k views

How to automatically turn off “hlsearch” after I'm done searching?

I love the "hlsearch" setting, but after I'm done searching, I find it obnoxious. Especially if I search for something that has a lot of matches. I know that I can turn this off with :set nohlsearch ...
13
votes
2answers
785 views

Auto Highlighting identical lines text

I saw a skilled vim ninja do this a while back but I have no idea were to start. A) Is there a way to set up vims background colour so that consecutive lines with identical content get highlighted. ...
12
votes
2answers
3k views

What is the functional difference between :nohlsearch and :set nohlsearch?

I noticed that when I use :nohlsearch that it does not actually do the same thing as :set nohlsearch. In particular, the hlsearch setting is not actually switched off (which is what :set hlsearch) ...
12
votes
3answers
600 views

Highlighted undo in Vim

I'm trying to have a highlighted undo in Vim, like spacemacs default config. Sometimes when I want quick undo's, I can't realize what changed because it's instantaneous. So I am trying to have ...
11
votes
7answers
2k views

How to search for lines matching current line in vim

I usually search for words by :/string, but if I have to search entire current line, how to do that. event: 1 beacon: 0x02 //line 1 event: 19 beacon: 0x02 //line 2 event: 1 ...
11
votes
1answer
548 views

Where do custom highlighting rules belong?

Occasionally I want to override the default syntax highlighting colours and styles with my own preferences. I imagine the most appropriate way to do this would be to create my own colorscheme. ...
11
votes
1answer
587 views

Is there an incsearch for the replace command?

I really enjoy Vim's incsearch functionality. Is there a way to have it, or something similar to it, working while I do a replacement? For example, if in normal mode I type: :%s/potato/ Can I get ...
10
votes
1answer
274 views

To print with search results highlighted

When we search a pattern in vim, the matches are usually highlighted. However, when we print it out, the highlights disappear. I tried both :hardcopy > my_file.pdf and :TOhtml. Neither retains the ...
10
votes
1answer
1k views

How can I highlight matching “%” names (e.g. if/end, for/end) defined by matchit.vim on selection?

Currently my Vim highlights matching parentheses, brackets, quotes, etc. with Cyan background and white foreground -- the cursor can be moved between these with %. Thanks to my matchit.vim, I can also ...
9
votes
1answer
2k views

Why do custom highlights in my vimrc get cleared or reset to default?

I would like to highlight (part of) my statusline with %1*, for example: set statusline=%1*%f%0* highlight User1 ctermbg=0 ctermfg=10 cterm=bold However, this always shows up as "empty" (the default ...
8
votes
1answer
3k views

Is there any way to change the popup menu color?

Is there any way to change the background color of the popup menu in gvim? The default background color is pink, which is a little weird to me.
8
votes
1answer
496 views

Visual select current search result

I have hlsearch set, but it sometimes lulls me into thinking t hat I have the search term visually selected, and can just hit c to change it. The term searched for may not be an easy number of ...
8
votes
1answer
214 views

How to color comments after a defined column

I once was given these materials to enable this helper for vim to show kind of a vertical line in order to help enforce PEP8 rules on line length limit at column 80: " Long lines highlighting. ...
8
votes
1answer
286 views

`echon` for `echomsg`

The echon and echohl commands are very useful for outputting lines of text with multiple highlight groups within the same line. This can be used to for instance create nice status messages for plugins....
8
votes
2answers
416 views

Why does vim blink randomly when I'm navigating through code?

# vim --version VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07) # cat /root/.vimrc map <F2> :w\|!sh % <cr> map <F3> :w\|!bash % <cr> map <F4> :w\|!...
7
votes
0answers
449 views

Highlight line number of folded lines

I want to have uniform highlighting of line numbers (provided by the LineNr and CursorLineNr hl-groups) but the line numbers of folded lines don't obey a particular group (as far as I know), but obey ...
6
votes
4answers
922 views

How to highlight/match (but not search!) the word under cursor

I am searching some pattern, navigate between search results, and at the same time I want some other pattern to be highlighted. For example, I jump between invocations of some function in my project, ...
6
votes
1answer
2k views

How to dim characters from :set list

I like to have :set list on so that I can tell if things are spaces or tabs. My tabs show as >--- which is nice, but they are the same color are the text, is there a way to dim them so they're less ...
5
votes
4answers
1k views

Stop highlighting when entering Insert mode

I would like Vim to stop highlighting matches when entering Insert mode. And not to highlight them again until a new search is performed. A first thought would be to add the following line to my ....
5
votes
1answer
804 views

Change color of misspelled words in vim-lexical

How can I change the color that is used to highlight misspelled words in vim-lexical?
5
votes
1answer
90 views

Highlight words with no other occurence in file

Say I have a list of strings in my code, for example : var array = [ "foo", "bar", "John", "Doe", "Mary" ]; test("foo"); test("bar", "Doe"); Those strings are repeated at the ...
5
votes
1answer
7k views

Modify vimdiff highlighting

For readability I try to modify my ~/.vimrc to get some proper highlighting. I found here to use e.g. this: highlight DiffChange cterm=none ctermfg=fg ctermbg=Red gui=none guifg=fg guibg=Red Like ...
5
votes
2answers
1k views

Vim lost custom highlight settings after recovering from sessions

I defined some highlights in the vimrc file and it works well in gvim. However after I mksession and sourced it back, I found that some (maybe all) of the custom highlights were lost and vim used the ...
5
votes
1answer
600 views

Search and highlight two different strings in different colors

I have a situation with typesetting a book in which the quotation marks are all screwed up. The author used a variety of marks¹ and apparently didn't believe in discriminating between them. I've ...
5
votes
1answer
544 views

Why does Vim highlight every dot in my code?

I program with Python and I installed python-mode with pathogen. Everything was fine but then suddenly Vim started highlighting all the dots in the files. And it's kind of frustrating. I thought it ...
5
votes
2answers
364 views

Set highlight in vim function

I am trying to highlight a word in the current buffer dynamically like so: function! Highlight() let @/ = 'word' set hlsearch endfunction When I run this function, the register / contains word ...
5
votes
1answer
135 views

How to make vim text bold?

In order to have my vim text always bold, I found this config in stackoverflow: :hi MyGroup cterm=bold :match MyGroup /./ But somehow, it has messed up search highlighting. It is no longer ...
4
votes
3answers
1k views

How to disable search highlight automatically after searching?

Search highlight is very convenient for me when I'm searching, but after I'm done with doing stuff with search matches it's distracting to me, so I'm using :noh mapped to F3 everytime I've done what I ...
4
votes
1answer
714 views

How to clear previous search highlight in vim? [duplicate]

After performing some search operation vim highlights its occurrences. These occurrences persist as long as editor is opened or another search is performed. How to clear previous search highlights ...
4
votes
1answer
526 views

Why is `:highlight Cursor …` ignored?

My color scheme has: hi Cursor ctermfg=black ctermbg=red cterm=NONE This is confirmed using hi Curosr: Cursor xxx ctermfg=0 ctermbg=1 guifg=black guibg=orange However, I'm not ...
4
votes
2answers
506 views

How to highlight a search range?

I'd like to test the range pattern, same as Vim highlights the text while searching (e.g. :/), but for the range command instead. So in other words, instead of executing: :/<head/,/\/head>/d ...
4
votes
2answers
160 views

Keystroke to move cursor to the last character of a highlight?

In Visual Mode, you can do this using the o keystroke. However with search highlighting, ie ? or / -- I have a whole selection, but I want to move specifically to the last character of the highlight....
4
votes
1answer
818 views

Echo highlighted warning in one line

I found from the vim's manual that we can echo colored text by the following command: :echohl WarningMsg | echo "Warnging" | echohl None | echo ":Some warning" which will highlight the string ...
4
votes
2answers
2k views

Toggle highlighting of trailing whitespace

I put the following lines from this page into my ~/.vimrc to highlight trailing whitespace in red: highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ autocmd BufWinEnter * ...
4
votes
1answer
336 views

Can I show a color from its hex value in *any* file?

We have vim-css-color to display colors in .css files. Currently I'm editing my i3wm config to match colors to a new terminal theme and it would be quite handy to be able to actually see colors I'm ...
4
votes
3answers
512 views

Run a function once on every paragraph

I'm trying to write a plugin that highlights overused words. After much effort I managed to write a function (and a command, :Ditto) that will highlight the most used word in the file or in a ...
3
votes
4answers
1k views

How to show illegal whitespace (such as unbreakable space) in source code?

I sometimes type (by accident) shift-space, inserting unbreakable space into code. With c++, I get this: error: stray ‘\302’ in program error: stray ‘\240’ in program while in other formats (like ...
3
votes
1answer
1k views

How to set value of cterm to both bold and underline?

Currently, my vimrc has set cursorline hi CursorLine cterm=underline ctermbg=none ctermfg=none I want to be set cterm to both underline and bold
3
votes
2answers
293 views

How do I get consistent behavior with matchadd color column?

After watching Damian Conway's talk, I added the following two lines to my .vimrc. highlight ColorColumn ctermbg=magenta call matchadd('ColorColumn', '\%81v', 100) My objective is to get the 81st ...
3
votes
3answers
105 views

Turn off highlights when pattern is entered

I find :set hlsearch useful while I am entering the pattern; but I want the effect of :noh as soon as I press enter. Is that possible?
3
votes
2answers
180 views

Is there anything like matchaddpos() but stick the highlight with the character instead of grid?

Assume we have this text: baaa matchaddpos("Error", [[1,2]]) highlights the second character (the first 'a') as "Error" group. baaa ^ highlighted When I insert a 'b' at the beginning, it becomes ...
3
votes
1answer
49 views

Highlighting only in a certain file

At every opening of a special file I want vim to automatically highlight all the lines, where the 7th character is a 1. How do I do that?
3
votes
1answer
244 views

Vim highlights long lines for all files

I have the following setting in my .vimrc for highlight long lines (>79) for python files augroup vimrc_autocmds autocmd! autocmd FileType python,rst highlight Excess ctermbg=DarkGrey guibg=...
3
votes
1answer
519 views

Aditional SQLite syntax highlighting in VIM

Currently I'm editing some SQLite scripts with my filetype set to ft=sql and some types aren't being highlighted and : REAL TEXT There is some configuration that I'm missing ? I've searched for a ...
3
votes
1answer
54 views

How do you get two `match`es at the same time to work? [duplicate]

I have two match lines in my vimrc. they work when they are used by themselves but when i try to uncomment both i don't get any matching behavior: " highlight spaces used for indenting match Visual /^...
3
votes
2answers
227 views

How to restore a search highlight state after searching for trailing space?

I would like to: First, save the current highlight state (nohlsearch? or hlsearch?). ...the current cursor position and the current search pattern. Then search for the trailing spaces, highlighting ...
3
votes
1answer
95 views

Get immediate feedback about a search string with no matches in vim

Is there a way to immediately get feedback about a search string with no matches? At the moment I have to press Enter first to get Pattern not found. I'd like if the background (of the search line or ...