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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.