Skip to content

Instantly share code, notes, and snippets.

@patrickward
Created November 9, 2010 17:08
Show Gist options
  • Select an option

  • Save patrickward/669401 to your computer and use it in GitHub Desktop.

Select an option

Save patrickward/669401 to your computer and use it in GitHub Desktop.
A few notes I've found useful as I move from TextMate to Vim

Moving from TextMate to Vim

Word Completion

I got quite used to TextMate's easy word completion, which is triggered with esc, and shift-esc. You can do something similar in Vim by using the ins-completion feature.

While in insert mode, use ctrl-n to search forward for the next matching word or ctrl-p to search backwards for the next matching line.

Checkout :help ins-completion inside Vim for more details.

Adding Snippets

The SnipMate plugin adds the ability to create snippets similar to TextMate's snippets. They work surprisingly well. And, the plugin comes packaged with snippets for over 18 languages.

Surrounding Elements

I used TextMate's feature of quickly surrounding text with html tags, parentheses, quotes, etc. rather extensively. To add that same functionality to Vim, you can use Tim Pope's Surround plugin, which adds mappings to add and replace any surrounding element such as a parantheses, a bracket, tags, etc.

It takes a little getting used to, but once you start getting into the Vim way of doing things, the keycodes become very easy to remember.

Add TextMate Mappings for shifting text

I'm used to the easy way that TextMate shifts blocks of code left and right using the command+[ or command+] shortcuts. To enable that same functionality in Vim you can add the following to your vimrc file:

nmap <D-[> <<
nmap <D-]> >>
vmap <D-[> <gv
vmap <D-]> >gv

This tip, along with a number of other useful tips can be found at vimcasts.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment