Coda Clips for Vim
I am currently trying to switch from Coda (Mac IDE) to Vim. One thing I loved about Code, and my knowledge of Vim cannot replace the so-called "clips". Basically, you type, say, "new", press TAB, and the text is replaced with a base XHTML page. And you can add as many keyword / clip combinations as you like.
The most I could get with Vim is to create a new file containing my clip and then use : r FILE in Vim to get it inserted, but this is not a very elegant solution as I have to wrap these clips in each directory. I have a file that I want to use my clips with.
So, assuming I have explained correctly, what will be my choices?
a source to share
For different editors, there is a functionality called '' 'snippets' '' where a tab expands the beginning of a common text (like an HTML definition or a C function definition) into a skeleton for that code.
There are a couple of vim plugins out there that provide this functionality. Two of my bookmark lists:
I heard about another quick HTML editing plugin that used snippets recently:
Check them out and see if they are close to what you are looking for.
Alternatively, you can define a BufNewFile
default action in vim that allows you to read into the skeleton of a file if it doesn't already exist automatically.
*skeleton* *template*
To read a skeleton (template) file when opening a new file: >
:autocmd BufNewFile *.c 0r ~/vim/skeleton.c
:autocmd BufNewFile *.h 0r ~/vim/skeleton.h
:autocmd BufNewFile *.java 0r ~/vim/skeleton.java
Put those (or the equivalent) in yours .vimrc
(without the leading colon) so that they auto-adjust each time vim starts.
a source to share
Very late to the party, but:
I would recommend something like Dash for this, because the fragments are then available across all of your applications.
This can be a significant benefit as your mouse memory starts to rely on certain chunks, and it also makes it easier to navigate from one editor to the next because your chunks are independent.
Sometimes I find myself using snippets in something like Mail to send to someone else, or in a Vim terminal on a remote machine that I haven't configured, and it's great that they're all ready there.
Now all we need is a cross-platform solution that moves with you to a colleague's computer!
a source to share
Like various snippet plugins, Vim also has a built-in abbreviation using the command :ab[breviate]
.
For example, you can define this:
:ab <h <head>^M</head>^M<body>^M<\body>
Then when you type <h<SPACE>
it will expand to full text. ^M
in the above example, it is actually a carriage return inserted into the line definition with <ctrl-V><RETURN>
.
a source to share