Friday, April 16, 2010

Capture output of a command

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.

Monday, April 12, 2010

Save file owned by root

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>.

Thursday, February 04, 2010

[link] Scripting the Vim editor, Part 3: Built-in lists

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.

Sunday, December 13, 2009

[link] Vim 401: Extending Vim and More

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.

Thursday, November 26, 2009

[link] Vim 101: A Beginner's Guide to Vim

Vim 101: A Beginner's Guide to Vim by Joe Brockmeier.

Bit too vi-ish IMO, yet as beginner's guide quite complete.

Saturday, August 15, 2009

[link] vi Introduction

vi Introduction. Obviously by "vi" they mean "VIM".

Friday, August 07, 2009

[link] Vim Tutorial

Vim Tutorial - with videos!

Bit too vi-compatible to my tastes. Otherwise most bases are covered.

Thursday, July 30, 2009

Friday, July 17, 2009

[link] Customizing vim and coloring the terminal in OpenSolaris 2009.06

dd if=/dev/random of=/dev/blog » Customizing vim and coloring the terminal in OpenSolaris 2009.06.

Hehehe. Somebody tries to make some use of Solaris.... Good Luck. Piece of advice though: upgrade to Linux, it's faster that way. Do not get me wrong... ... BUT WHAT THE F***?! This is year 2009 and Solaris still can't take care of colors?

P.S. BTW, Good Luck trying to use "TERM=xterm-color" though. Last I time I tried it on Solaris only to find that it is lacking something like half keyboard.

Really. Get over it, swallow your childish pride and get the Linux. It works.

Monday, July 06, 2009

[link] Speed-Typing in Vim With Maps and Abbreviations - Better Than a Clipboard

LinuxPlanet - Tips - Speed-Typing in Vim With Maps and Abbreviations - Better Than a Clipboard.

Some nice tips on how to use VIM's abbreviations to insert some dynamic (not static!) text like e.g. current date.