[link] Vim 7.2 Scripting
Rundown on a number of simple things one encounters when starting scripting: version check, OS check, debugging.
Rundown on a number of simple things one encounters when starting scripting: version check, OS check, debugging.
Posted by
Ihar Filipau
at
9:00 AM
0
comments
Labels: link
My usual trick of using vim with grep works well when single grep invocation is sufficient.
Yet quite often I end up piping one grep's output to another grep to refine the results. And that doesn't work with my old trick of wrapping the grep MethodName *.cpp into vim -c ":grep MethodName *.cpp" as the vim's internal grep doesn't support pipes.
Digging through the documentation I found that it is possible to accomplish and it fits well to my workflow.
Start grepping(*):$ grep MethodName *.cpp # not fine enough...
$ grep MethodName *.cpp | grep -v rubbish # much better
# and save to a file
$ grep -n MethodName *.cpp | grep -v rubbish > tmp1.out
N.B. -n to the grep is required as VIM needs line numbers to jump to the locations.
And now tell VIM to use the produced tmp1.out error file:$ vim -q tmp1.out
or$ vim -c ":cf tmp1.out"
or from inside running VIM::cf tmp1.out
Check the :h :cf for the official documentation.
(*) Obviously in the case it doesn't have to be grep - anything what produces similar output would do. I used once a perl script to generate VIM-compatible error file from diff output to preview potential merge conflicts.
Posted by
Ihar Filipau
at
7:17 AM
0
comments
Labels: grep
I was playing around with ^K and wanted to see all possible combinations available. :help CTRL-K directed to the :digraphs command. The problem is that amount of output from :dig eclipses even that of the :set all.
So how one can somehow serialize the output into e.g. a VIM's buffer?
Search on the net unveiled the following tip::redir @a
:dig
:redir END
Or even cooler, putting the output into a variable::redir => varname
:dig
:redir END
followed by echo varname.
Final step is the dumping all that into a buffer/window: :put =varname.
P.S. The official Learn to use help article. Til now, I haven't knew that the :help could be abbreviated to the :h.
Posted by
Ihar Filipau
at
4:52 AM
0
comments
Have just seen the nice trick on the Interwebs.
It happens often: one starts editing a file owned by root. One gets used rather quickly to the VIM's warnings about editing a file one does not have permissions to. Only much later realizing that you can't save it.
So you opened a VIM and edited a file, but can't save it. Instead of saving a temp one can use the trick::w !sudo tee %
P.S. ZOMG PONYZ!!1 For what I was always adding a custom shortcut :map <F6> :b#<CR> turned out to have an official shortcut: ^6 (:help CTRL-6). In VIM 7.1, this is sole shortcut of the form CTRL-<number>.
Posted by
Ihar Filipau
at
2:42 AM
1 comments
Scripting the Vim editor, Part 3: Built-in lists, part of Scripting the vim editor series over at IBM's dW.
Insightful read. Though I hope I would never need to script the VIM to such extent.
Posted by
Ihar Filipau
at
5:26 AM
0
comments
While I was procrastinating here, the Joe Brockmeier guy is already on fourth installment of his articles dedicated to learning Vim: Vim 401: Extending Vim and More.
Do not forget to check the links (provided in article) to the previous installments.
Posted by
Ihar Filipau
at
3:43 AM
0
comments
Vim 101: A Beginner's Guide to Vim by Joe Brockmeier.
Bit too vi-ish IMO, yet as beginner's guide quite complete.
Posted by
Ihar Filipau
at
5:10 AM
0
comments
vi Introduction. Obviously by "vi" they mean "VIM".
Posted by
Ihar Filipau
at
1:45 AM
0
comments
Vim Tutorial - with videos!
Bit too vi-compatible to my tastes. Otherwise most bases are covered.
Posted by
Ihar Filipau
at
3:02 AM
0
comments