[lug] 2 more vim questions
horlenkarl at yahoo.com
Thu Mar 1 16:48:52 MST 2007
> > 1) In vi/vim, there is a way to reveal/show/print
> > the lines that match a certain pattern.
> > (alternatively hide all the lines that don't match
> > pattern).
> > I used to use this a couple of years ago and i
> > figure out how to do it any more. anybody know
> :help :v
I'll take a gander at v. however i think found what i
used to use:
that's a basic print command or print with line number
prefixes. that searches the entire file (g) for said
pattern and then ONLY prints those matching lines.
the problem with MY method is:
1) that you can't select/yank or copy those MATCHING
lines for pasting elsewhere?
2) you can't redirect the output via > filename (or at
least i haven't found the right command) to save the
3) 1 and 2 are compounded by the fact that sometimes
the results are bigger than one screen and they are
paged with more.
I could just use sed or grep for this but i'm sure it
can be done from withIN vim. especially since i
sometimes run it on windows without sed or grep.
anybody know how to extend my print commands to allow
for yanking or redirecting the results?
> > 2) vim does automatic syntax highlighting on
certain file extensions
> Add a comment to the end of the file like:
> // vim:ft=php::
however, you have to manually set that in each file..
i just found how to do this automagically though:
there is a filetype.vim file that exists in your root
directory. search for your extension until you find a
line similar to the following:
"au BufNewFile,BufRead *.php,*.php3 setf php
then just add the extension you want to be
automatically considered taht filetype:
au BufNewFile,BufRead *.newexetnsion,*.php,*.php3
It will automatically get detected now.
> The hardest thing about Vim for me is remembering
> where in the docs to find
> things like that.
you got that right.. it's also become so configurable
with so many esoteric options that it's hard to find
them or even search for them in a meaningful way
however, it's those esoteric options that make vim so
powerful and useful assuming you know what they are
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
More information about the LUG