Archive

Posts Tagged ‘Vim’

A Small but Effective Tweak to Vim’s snipMate plugin

February 6th, 2010 No comments

Already awesome

If you haven’t tried snipMate, you have to give it a test-drive.  If you want to define a new ruby class in Vim, type “cla<tab>” and you’re presented with your choice of class templates:

Enter a number, and the code is automagically generated for you.

The tweak

By default, hitting enter at the menu cancels the snippet.  However, a user can already easily cancel using escape, and this probably won’t happen all that often anyway (I don’t think ever for me).  So I altered the code to choose the first (most common) snippet if no number is entered.  This saves me a non-home-row keystroke in almost 100% of my usage.

The code

In plugin/snipMate.vim, comment out the last line of the s:ChooseSnippet function and add two lines in it’s place:

fun s:ChooseSnippet(scope, trigger)
  [snip...]
  " Original last line (which cancels on enter) commented out
  "return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]

  " Two lines added to choose first snippet if none are selected
  let snip_to_return = num == -1 ? 0 : num
  return s:multi_snips[a:scope][a:trigger][snip_to_return][1]
endf

Pretty simple, huh? Oh, just remember to save a copy of the changed lines somewhere.  When you update the plugin, your changes will be erased and you’ll have to re-paste them.

Categories: Programming Tags:

Cucumber.vim

December 12th, 2009 No comments

Awesome plug-in!  Uh, ok… but what the heck does it do?!?!  Here’s a list of the goodness:

  • syntax highlighting

  • Jump to steps
    • CTRL-] opens the step definition in the current window
    • CTRL-W ] opens it in a split window (optionally hold CTRL with the ‘]’)
    • CTRL-W opens in a split preview window
  • Autocomplete – it seems from the source that it should work, but I can’t get it going.  I posted a question on the cucumber mailing list.
    Categories: Programming Tags: ,

    Ruby, Vim, and Windows

    December 11th, 2009 2 comments

    It is unbelievably easy to create a wicked setup, although I spent half a day googling to narrow it down to the exsentials:

    Downloads

    1. Ruby with the One-click installer.
    2. Vim’s self-installing Windows executable (this comes with many customizations you read about online, and ruby support, included)
    3. snipMate, a plug-in that automatically expands common Ruby constructs (e.g. you type ‘cla<tab>,’ which becomes class…end with placeholders!)
    4. AutoComplPop (must have!!!), an autocomplete plugin very much like Xcode’s – start typing and a popup list of completion options appears.  superTab, another plug-in that allows you to use tab to auto-complete Ruby code
    5. wombat, a great color scheme

    Global configurations

    Add the following settings to /path/to/vim/_vimrc.

    note: the autocomplete menu colors, and vim’s default font are disgusting, hence the changes.

    Ruby-specific Configurations

    In the vimrc above, the following is added:

    • the first line sets up superTabs to look in the right place for Ruby completions (I use AutoComplPop now, see above)
    • adds line numbers to several source code file types
    • changes the ridiculous 8-space tabs to 2

    That’s it!  Happy coding :)

    Categories: Programming, Ruby Tags: , ,

    windows 7 product key

    windows 7 product key

    windows 7 key generator

    windows 7 key generator

    free winrar download

    free winrar download

    winzip activation code

    winzip activation code

    free winrar

    free winrar

    winzip free download

    winzip free download

    winrar free download

    winrar free download

    winrar download free

    winrar download free

    winzip free download full version

    winzip free download full version

    windows 7 activation crack

    windows7 activation crack

    windows 7 crack

    windows 7 crack

    free winzip

    free winzip
    \n