This is something that partly is provided by vim by folding. But I don't want the folding texts...
What I want is to watch a file in two views where the second one is a filtered view of the first one.
Can anyone please help me. I'm not a very advanced user
Q. I would like to have a dual view of my file with many thousand lines.
A. I could do this with a vertical split.
Q. Then I would like to two windows to be synchronized.
A. I could do this with the :scrollbind command
So far everything is good... But then:
Q. I want to filter the view to only show text matching my regex
A. There's a VIM-tip's for that:
:set fold
:set foldexpr=getline(v:lnum)!~@/
:nnoremap <F8> :set foldmethod=expr<CR><Bar>zM
The problem is that I cant get rid of the text: "+--27 lines: xxx-----------------"
I would like a list of all lines containing my regex and nothing else. The output I would like is similar to the output generated by this command:
:g!/MyRegEx/d
but I don't want to delete the text since I want to edit the complete file (but in a filtered view)
The second problem I get is that I want to :scrollbind to completely sync the lines between the current cursor line in my filtered window with the line i my unfiltered windows so that I could see the surrounding text
Example:
Windows 1 (original)
========
1 Line 1
2 Line 2
3 Line 3 foo
4 Line 4
5 Line 5
6 Line 6 foo
7 Line 7
Windows 2 (filtered on /foo/)
========
3 Line 3 foo
6 Line 6 foo
I'm not recommending this, but as a matter of interest the "Conceal" patch includes
the 'cursorbind' option.
http://groups.google.com/group/vim_dev/web/vim-patches
John
Marc
You may want Vim to display the relevant lines as a message rather than
as an edit buffer: see ":help :g"
For instance, to display only the lines contining the words "foo" and
"bar" in that order (each as a word, without quotes, and with anything
between them), you might use
:g/\<foo\>.*\<bar\>/p
(From quickfix.txt lines 614-615:
[Unix trivia: The name for the Unix "grep" command comes from ":g/re/p",
where
"re" stands for Regular Expression.]
)
Best regards,
Tony.
--
"When I get real bored, I like to drive downtown and get a great
parking spot, then sit in my car and count how many people ask me if
I'm leaving."
-- Steven Wright
P.S. See also ":help :redir" about capturing, for instance, the output
of ":g/something/p".
>
>
> Best regards,
> Tony.
--
The pitcher wound up and he flang the ball at the batter. The batter
swang and missed. The pitcher flang the ball again and this time the
batter connected. He hit a high fly right to the center fielder. The
center fielder was all set to catch the ball, but at the last minute
his eyes were blound by the sun and he dropped it.
-- Dizzy Dean