Because I often want to concentrate on a small section of code in a large
script, and because my terminal window is large, I wondered if it was possible
to select some text and have all other text, ie. the surrounding text, fade out
in colour, or use a darker colour or something, so that when I flick away to
read another tab and flick back, I don't have to manually search out the small
block of code again.
vnoremap h :<c-u>exec 'match Comment
/\%<'.line("'<lt>").'l\\|\%>'.line("'>").'l/'<cr>
seems to do what you're describing (that "|" might have to be
"<bar>" depending how vnoremap treats things in strings...).
Adjust "Comment" to be whatever highlight group you like...or
make your own and make it invisible. For me, Comment is
[italic-]dark-grey-on-black which fades out. Then, with a block
highlighted, you can hit "h" and it will "mask" all the stuff
that wasn't highlighted.
As usual, you can then just
:match none
to clear it.
Now I'm wondering if it is possible to select a block of text and issue a fold
command that folds away everything BUT the selected text.
A similar stunt could be done to clear all folding, and then fold
the two ranges "1,'>-" and "'>+,$" something like this untested
vnoremap h :<c-u>1,'<lt>-fold<bar>'>+,$fold<cr>
HTH,
-tim