A
If you just want to quickly confirm the validity of the range (and it isn't too long), you can use the built-in :print
or :number
:
:/<head/,/\/head>/print
B
Another idea would be (mis-)using the visual selection. The following custom command creates a linewise selection of the passed range:
":[range]SelectRange Create a linewise visual selection of [range].
command! -bar -range SelectRange execute "normal! m'" | call cursor(<line1>, 1) | execute 'normal! V' | call cursor(<line2>, 1)
:/<head/,/\/head>/SelectRange
C
If you really want some (semi-permanent) highlighting, you can use :match
with one of the following custom commands:
hi link Match Search
":[range]MatchLines [{group}]
" Highlight the lines in [range] with the "Match" group /
" {group}. This only considers the line numbers, not their
" contents.
command! -bar -range -nargs=? MatchLines execute 'match' (empty(<q-args>) ? 'Match' : <q-args>) printf('/\%%>%dl\%%<%dl/', (<line1> - 1), (<line2> + 1))
":[range]MatchRange [{group}]
" Highlight the content of the lines in [range] with the
" "Match" group / {group}. This considers the current
" content of the lines (also elsewhere in the buffer).
command! -bar -range -nargs=? MatchRange execute 'match' (empty(<q-args>) ? 'Match' : <q-args>) '/\V\^' . join(map(getline(<line1>, <line2>), 'escape(v:val, "\\/")'), '\n') . '\$/'
Clear with :match