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.
Sunday, December 13, 2009
Thursday, November 26, 2009
Saturday, August 15, 2009
Friday, August 07, 2009
Friday, July 17, 2009
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.
Posted by Ihar Filipau at 3:14 PM
Monday, July 06, 2009
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.
Posted by Ihar Filipau at 4:49 AM
Saturday, June 27, 2009
LinuxPlanet - Tips - Turning on Unicode Support in Vim - Unicode in Vim.
Though article is more about how to input all those fancy characters.
Posted by Ihar Filipau at 7:02 AM
Friday, June 05, 2009
One - at times very - annoying problem I had was that jumping to tag not very C++ friendly. Namely it doesn't consider ':' (colon) to be part of word under cursor. It finally bothered me to the point of reading documentation which promptly sent me to
:help star where from I was sent to
:help 'iskeyword'. In less than a minute I had a fix:
au BufReadPost *.cpp set isk+=:
'isk' is shorthand for 'iskeyword' and tells VIM what symbols should be considered to be part of (key)words. 'isk' is a list (as usually comma separated) of characters/character ranges and as with any other comma-separated lists, operators '+=' and '-=' do they job as they should.
That obviously has an impact on any VIM command which works with words - '*', '#', 'w', etc. Beware.
Tuesday, May 19, 2009
Vim made easy: how to get your favorite IDE features in Vim by Ryan Paul on ArsTechnica.
Something about plug-ins and such. Lots of screenshots with Python source code, so I couldn't look deeper.
Sunday, April 26, 2009
Handle With Linux's my vi first steps.
I presume the guy means "vim" as he's working with Linux and Linux for past 10+ years has "vi" as a symlink to vim.
P.S. Nice trick to use :wn from a macro - to make macro to go to the next file. When macro invoked with repeat counter N, it would be applied to N first files open for editing.
Saturday, April 25, 2009
Thursday, April 09, 2009
Wednesday, February 11, 2009
For a long time it had annoyed me that pressing PageUp or PageDown would not only go to previous/next screen portion of file, but would also screw cursor position. Essentially, unlike good ol' DOS editors, in VIM pressing PageDown followed by PageUp (or vice versa) would send cursor to the start of first visible line - not back to the position where it was before. Especially as I now work more on my notebook's cramped keyboard (which btw has full sized keyboard, yet no keypad and no dedicated PageUp/PageDown keys) hitting by accident any of the keys requires some seconds to recover cursor position.
It annoyed me to the point of trying to make a VIM script to PageUp/PageDown properly.
But thankfully I have sobered up and my always questioning mind aksed: "Do you idiot think that you are the first annoyed by that? Don't you think VIM folks already have a feature for that??"
So finally I read as resourceful as ever :help - and my Eureka! awaited me right there, few lines above ":help <PageUp>". Now my ~/.vimrc has this:
map <PageUp> <C-U>
map <PageDown> <C-D>
imap <PageUp> <C-O><C-U>
imap <PageDown> <C-O><C-D>
Essentially, PageUp and PageDown are now mapped to ^U and ^D respectively. The difference is that ^U/^D do preserve cursor's relative line number (relative to first visible line). ^U/^D work in normal mode, thus the ^O trick is needed to access it from insert mode.
The final nail - ":set nostartofline" - tells VIM during motion commands to try to preserve column where cursor is positioned.
You cannot possibly imagine how happy I am ;)
Update1. I felt something was wrong - but couldn't tell it immediately. Apparently, unlike PageUp/PageDown, ^U/^D move cursor only by half of screen. In other words, to emulate PageUp/PageDown, they have to be triggered twice:
map <PageUp> <C-U><C-U>
map <PageDown> <C-D><C-D>
imap <PageUp> <C-O><C-U><C-O><C-U>
imap <PageDown> <C-O><C-D><C-O><C-D>
Now that's much better.
Update2. Here goes improved version:
map <silent> <PageUp> 1000<C-U>
map <silent> <PageDown> 1000<C-D>
imap <silent> <PageUp> <C-O>1000<C-U>
imap <silent> <PageDown> <C-O>1000<C-D>
It turned out, ^U and ^D look at the counter for how many lines to scroll. Yet, they would scroll up to screen size. Thus specifying large value would make the shortcuts to scroll full screen at once. And you have to use counter all the time. Read more in
:help CTRL-U and
:help scroll. I'm not sure what led to the messy design (try
:set scroll=NN) yet the mappings as above work fine.
With version from "Update1" especially on large files when triggering e.g. ^U^U it would be still visible that the scrolling happens in half screen steps. With the version that doesn't happen anymore as VIM now is properly told how many lines to scroll. As there is now counter involved, adding silent option is required.
This is logical follow-up to my previous post about K shortcut.
The two (actually three lines) added to ~/.vimrc allow when editing Perl and VIM scripts to transparently call with K proper help system.
au BufReadPost *.pl set keywordprg=perldoc\ -f
au BufReadPost *.vim map K :exe ":help ".expand("<cword>")<CR>
au BufReadPost .vimrc map K :exe ":help ".expand("<cword>")<CR>
Perl one is obvious. VIM one actually required some trickery: we do not call external program, but call VIM's internal command instead.
:help :helpis pretty useful reading. Due to my error, 'K' in VIM mode used to constantly show it, instead of expected 'expand("<cword>")'.