Adding vim snippets
Asked Answered
C

2

6

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?

Conk answered 19/2, 2013 at 9:32 Comment(0)
I
10

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.

Investigator answered 19/2, 2013 at 11:27 Comment(1)
Note: this solution has the advantage that it is compatible with plain-vanilla vim and does not require any additional language plugins (e.g., python)Timoshenko
A
8

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.

Attila answered 19/2, 2013 at 9:55 Comment(1)
Giving a recommendation without giving any reasons for it is not useful, in my opinion. Why not say why?Bund

© 2022 - 2024 — McMap. All rights reserved.