Saturday, April 28, 2012

Vi niceties

This last Railsberry there was a very fine Vim introduction/advocacy speech by Ben Orenstein from (yes, go check now, I'll wait)

There were plenty of vim showoff there on the talk, but one of the neat tricks caught my eye, and today I have used it for the first time, so here it is for you all to discover and hopefully for me to remember:

Vim Macro's Surgery:

Macros are one of Vim's most famous and least used (by beginners) features. As you progress along the path of Vi/m you start using them more often to avoid repetitive chores and menial tasks.

So far so good, but until now, if I was making a macro and got wrog, I had to start over and record a new one, Ben showed us better:

  • Record a Macro into the 'a' register:
  • Paste it:
  • Correct:
    <...macro editing...>
  • Yank it again:
  • Use it:
  • Or use it 42 times

On a side note, what I was doing today was edit teh configuration for a new pluging I saw at It is called CtrlP ang gets right everything control-t and Fuffile got wrong, so I recomend you to give it a try. You might need to tweak uo the highlights, depending on your colorscheme, so I leave the relevant doc reference here for your convenience:

CUSTOMIZATION                                             *ctrlp-customization*

  * For the CtrlP buffer:
    CtrlPNoEntries : the message when no match is found (Error)
    CtrlPMatch     : the matched pattern (Identifier)
    CtrlPLinePre   : the line prefix '>' in the match window
    CtrlPPrtBase   : the prompt’s base (Comment)
    CtrlPPrtText   : the prompt’s text (|hl-Normal|)
    CtrlPPrtCursor : the prompt’s cursor when moving over the text (Constant)

  * In extensions:
    CtrlPTabExtra  : the part of each line that’s not matched against (Comment)
    CtrlPBufName   : the buffer name an entry belongs to (|hl-Directory|)
    CtrlPTagKind   : the kind of the tag in buffer-tag mode (|hl-Title|)
    CtrlPqfLineCol : the line and column numbers in quickfix mode (Comment)
    CtrlPUndoT     : the elapsed time in undo mode (|hl-Directory|)
    CtrlPUndoBr    : the square brackets [] in undo mode (Comment)
    CtrlPUndoNr    : the undo number inside [] in undo mode (String)
    CtrlPUndoSv    : the point where the file was saved (Comment)
    CtrlPUndoPo    : the current position in the undo tree (|hl-Title|)
    CtrlPBookmark  : the name of the bookmark (Identifier)

  * Highlight groups:
    CtrlPMode1 : 'prt' or 'win', also for 'regex' (Character)
    CtrlPMode2 : 'file' or 'path', also for the local working dir (|hl-LineNr|)
    CtrlPStats : the scanning status (Function)

  For rebuilding the statuslines, see |g:ctrlp_status_func|.