|
Hello,
How do I hide first N lines of the file from view (like, using folds maybe ?). Even better, I want to hide, out of N first lines of file, those lines that match some pattern. Even better, how do I have vim show some 1-liner string (coming from the vim script) to show in place of the hidden lines ? (I am not dure this last item is possible, but I think the first two items are possible using folds.) Thanks Yakov -- [hidden email] -- http://www.fastmail.fm - IMAP accessible web-mail |
|
> How do I hide first N lines of the file from view (like, using
> folds maybe ?). Yes, using folds is likely the way to do what you want. in Ex mode (assuming N is 20) :1,20fold in Normal mode ggzf20G > Even better, I want to hide, out of N first lines of file, > those lines that match some pattern. Do you just want to hide select lines in the range 1..N, or do you want to hide lines 1..N where N is found by a pattern? If it's the latter you can do: in Ex mode :1;/pattern/fold in Normal mode ggzf/pattern > Even better, how do I have vim show some 1-liner string > (coming from the vim script) to show in place of the hidden > lines ? (I am not dure this last item is possible, but I think > the first two items are possible using folds.) Folding shows condenses multiple lines into a single "placeholder" line as you describe. Getting different behavior would actually be more work :) For more information, check out :help :fold :he zf :he gg :he G Hope this gives you what you were looking for, -tim |
|
Here's another approach, using fold expressions instead of manual
folds. First, :set foldmethod=expr :set foldlevel=0 On 2005-11-16, [hidden email] wrote: > How do I hide first N lines of the file from view (like, using folds > maybe ?). For example, let N = 20. :set foldexpr=v:lnum<=20 > Even better, I want to hide, out of N first lines of file, those > lines that match some pattern. :set foldexpr=v:lnum<=20&&getline(v:lnum)=~'pattern' > Even better, how do I have vim show some 1-liner string (coming > from the vim script) to show in place of the hidden lines ? (I am not > dure this last item is possible, but I think the first two items > are possible using folds.) This really depends on what you want your 1-liner string to be. It can be set via the 'foldtext' option. As an example: :set foldtext=MyFoldText() :function MyFoldText() : let n = v:foldend - v:foldstart + 1 : return 'This is a fold of ' . n . ' lines' :endfunction See :help usr_28.txt :help fold.txt HTH, Gary -- Gary Johnson | Agilent Technologies [hidden email] | Wireless Division | Spokane, Washington, USA |
| Powered by Nabble | Edit this page |
