I'm using Vim to write something where "pages" are important. Pages are a fixed number of lines.
I use :set colorcolumn
to highlight the right margin. Is there anything similar to highlight every Nth line of the file?
The solution 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 above in your .vimrc,
and call
:Highlightevery 10 1000
will highlight every 10 lines in to line number 1000.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With