Emma Tech

  • Emma Home
  • Emma Blog
  • Job Openings
  • RSS

Posts Tagged ‘Vim’

How to get TextMate’s best features in Vim

And code more efficiently to boot

Josh Mock 31 Mar 2011 editors Python tools Vim 7 Comments

The debate over the best cod­ing text edi­tor will never end. In our office, the two biggest camps belong to TextMate and Vim. (We have one Komodo user, but we leave him alone.) There are things I love about both edi­tors, but Vim’s modal, mouse-free, keystroke-efficient phi­los­o­phy even­tu­ally won. At first I thought I was sac­ri­fic­ing my favorite TextMate fea­tures by choos­ing Vim, but Vim’s script­abil­ity in the hands of its clever com­mu­nity pro­vided solu­tions for every­thing I missed, plus count­less other bonuses.

Below is a list of awe­some Vim plu­g­ins I now depend on daily. Several are unapolo­getic TextMate knock­offs done in a more Vim-like way. Others are solu­tions to other cod­ing annoy­ances that only Vim could do. Try out a few below and see if Vim doesn’t steal your heart. (Also, if you’re new to Vim, I sug­gest installing Pathogen first to pre­vent headaches.)

Replace TextMate with Vim

NERDTree: Load a direc­tory tree on the left side of the screen. It will open high­lighted files on the cur­rent screen or in a new tab. (Pro tip: use the leader key to map some key­strokes to avoid hav­ing to type :NERDTree /path/to/my/code/ every time.)

Command-T: For addicts of TextMate’s ⌘-T smart-filtering file launcher, this plu­gin recre­ates that func­tion­al­ity using the leader key.

Snipmate: TextMate lovers can’t live with­out snip­pets, so why should Vim fans have to? In a few key­strokes, gen­er­ate HTML stubs, Python func­tions and other repet­i­tive, often-used bits of code. It’s stocked with snip­pet libraries for many lan­guages, and adding your own is easy.

Make Vim do things TextMate can’t

SuperTab: In insert mode, the Tab key will cycle through a list of words to auto-complete what you’re typing.

TComment: Typing gcc will tog­gle com­ments for the cur­rent line of code in nor­mal mode. In visual mode, gc tog­gles com­ments for any high­lighted rows. It works in most com­mon pro­gram­ming languages.

VIM Surround: A few key­strokes will add, change or remove brack­ets, quotes and HTML tags around the cur­rent word, line or high­lighted text. It takes some time to get the hang of this one, but it is flex­i­ble and powerful.

Vim Indent Guides: Trace tab inden­ta­tions in your code. Very use­ful for long nested if/else state­ments and loops, mak­ing sure you close HTML tags and for read­ing lengthy chunks of indented code.

Jellybeans: Jellybeans is a dark color scheme that’s easy on the eyes. Put it in your ~/.vim/colors/ direc­tory (or $HOME/vimfiles/colors in Windows) and run :colorscheme jellybeans or put colorscheme jellybeans in your .vimrc.

Of course, these plu­g­ins only scratch the sur­face of what Vim can do. If you want TextMate’s code col­laps­ing, Vim can do that. If you want to com­pile or run code you just wrote, no prob­lem. If you are a Pythonista who lives by PEP 8 for­mat­ting, there’s a plu­gin (and a .vimrc hack) for that. Point being: TextMate is great, but with a lit­tle pok­ing around, Vim can do as much or more, often with half the keystrokes.

About Emma Tech

Emma's technology group brings you updates and shenanigans related to all things engineering.

Emma Tech on Twitter

    Follow Emma Tech »
    Help wanted

    • Popular Tags

      Python12 api7 UX5 conferences4 postgres4 workflow4 time4 javascript3 PHP3 jQuery3 tools3 editors2 travel2 server maintenance2 Git2 maintenance windows2 Haml1 Frank1 Ruby1 CSS1 PyCon1 office1 Sass1 downtime1 post‑mortems1 cgit1 books1 Trac1 collaboration1 community1 Twitter1 Facebook1 OAuth1 coding1 cool sites1 Redis1 github1 objects programming refactoring1 integration1 salesforce1 usability testing1 Social Posting1 music1 productivity1 bugs1 TextExpander1 san francisco1 Convore1 Vim1 releases1 legacy data1 HTML1 reading1 Django1 PgCon1 testing1 TDD1

    Emma is a member of the Email Sender & Provider Coalition and the Messaging Anti-Abuse Working Group.

    Copyright © 2003 - 2013 Emma.
    All rights reserved.

    • Get Emma's Newsletter
    • Visit the Emma Blog
    • @emmaemailtech on Twitter
    • @emmaemail on Twitter
    • Emma on Facebook

    Emma's email marketing makes communicating simple and stylish.
    Inquire now for more details.