sameera207
sameera207

Reputation: 16629

Adding vim snippets

I have found this resource for Ruby/Rails snippets, seems like it has lots of cool snippets that I could use with vim.

But since I'm new to vim, I don't know how to enable those snippets to my vim editor. There is no instruction manual as such.

How can I get these kind of snippets enabled in the vim editor?

Upvotes: 6

Views: 10195

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172788

Those snippets are for the snipMate - TextMate-style snippets for Vim plugin. You need to install it first.

Note that though this plugin isn't maintained any more, it's still working fine (and probably will continue to do so, due to Vim's great record of backwards compatibility), and is still used by many people (me included). There's a renewed fork available, though: garbas/vim-snipmate. A newer, more powerful plugin is UltiSnips - The ultimate snippet solution for python enabled Vim, which can convert the old snipMate snippets into its format. So, there's a lot of choice.

Upvotes: 10

Billy Chan
Billy Chan

Reputation: 24815

About Snippet Plugin in Vim

I recommend the plugin Neosnippets: https://github.com/Shougo/neosnippet This is the best in my opinion.

Step 1: Install plugin. Recommend using Pathogen to install

step 2: Download/clone a snippet repo you like to local machine, or create your own(recommeneded)

Step 3: Set the path of above repo as Neosnippets's snippets folder in vimrc

let g:neosnippet#snippets_directory='~/path/to/above/snippets/'

Step 4: Customize more if you like, according to the help file.

For the repo you mentioned

I checked it.

One problem is it's out of date, many Rails code are several years ago. They are of little use now.

The other problem is the format is not compatible with NeoSnippet. You can check :help neosnippet-snippet-syntax for how to write snippets for NeoSnippets. It's simple while easy to use.

Upvotes: 8

Related Questions