Vim: highlight every Nth line?

I use Vim to write something where "pages" are important. Pages are a fixed number of lines.

I use :set colorcolumn to highlight the correct margin. Is there something similar to highlight every Nth line of a file?

+6
source share
1 answer

The solution is below:

 function HighlightEvery(lineNumber, lineEnd) highlight myhighlightpattern ctermbg=darkred guibg=darkred let pattern="/" let i = 0 while i < a:lineEnd let i += a:lineNumber let pattern .= "\\%" . i . "l\\|" endwhile let pattern .= "\\%0l/" let commandToExecute = "match myhighlightpattern ".pattern execute commandToExecute endfunction command -nargs=* Highlightevery call HighlightEvery(<f-args>) 

Add the code to your .vimrc,

and call

 :Highlightevery 10 1000 

selects every 10 lines in line 1000.

+6
source

All Articles