Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM hide (not fold!) lines

Tags:

vim

Is there a way to totally hide certain lines? I do not want folding, I one them to not be visible at all.

Example: I program with php; functions and class variables have phpdocs, and I hate how much vertical space lines with nothing but /** and */ can take. Thus I would like to not show them (and most likely some other things). Though I have doubts that that is possible...

Note: I know about global commands and they don't do what I want. You can one of printing of what I want. But I want lines hidden in the editing area.

like image 761
morphles Avatar asked Jun 22 '12 07:06

morphles


2 Answers

You can make comments invisible:

:hi! Comment guifg=bg ctermfg=white

Or

:hi! link Comment Ignore
like image 57
kev Avatar answered Oct 03 '22 01:10

kev


I know this isn't really what you're asking for, but have you tried using folding with a blank foldtext? That way the lines a folded region appears like an empty line. To do this, set

set foldmethod=marker
set foldmarker=\/**,*\/
set foldtext='\ '

I prefer a foldtext which indicates that there's something there, possibly by making is look like a single commented line. In this case, replacing the first folded line with a single comment string // at the current indent level:

set foldtext=substitute(getline(v:foldstart),'\\/\\*\\*.*','\\/\\/','g'

I find this unobtrusive, while still reminding me that there is some hidden text.

Hope this helps.

like image 35
Prince Goulash Avatar answered Oct 03 '22 02:10

Prince Goulash