tags:

views:

139

answers:

2

I try to write :ab in Vim for faster coding but the question is can I write ab for each language .

Like in HTML : I write begincode : I'll be HTML DOC TYPE

in C++ : It'll be int main () { return 1; };

I'm a new beginner in Vim and I miss intellisense in visual studio, can I have it in Vim . I mean not only for C++, but another language too :)

Thanks for reading .

+5  A: 

You can write filetype plugins for the languages you'd like abbreviations for.

There's a full section in the documentation about this - type :help ftplugin within vim, or see it online. The ftplugins are named after the filetype they run for, for example cpp.vim for C++ code.

If this is just for you, you can place your filetype plugin in ~/.vim/ftplugin. For a example, for ~/.vim/ftplugin/cpp.vim you could write:

ab begincode int main () { return 1; };
ab authorheader /* Programmer: nXqd */
...

If you're interested, you can see all the built-in filetype plugins in the vim install's ftplugin directory - on most systems, that's /usr/share/vim/vimXX/ftplugin, where vimXX is the vim version (e.g. vim72 for Vim 7.2). If you have any additional ones installed system-wide, they'd be in /usr/share/vim/vimfiles/ftplugin.

Jefromi
Thanks . I really like /* Programmer : nXqd */
nXqd
I use gVim, thanks for great comment :)
nXqd
@nXqd: I'm not sure why you mention using gVim - on Linux, it uses all the same runtime files as vim, plus some extra. On other OSes, I believe the same directory structure is present, just with a different install directory - and perhaps the slashes flipped around.
Jefromi
A: 

Instead of going for your own file type plugin, i would strongly recommend c.vim plugin for you. That is one of the largely used vim plugin, where a lot of facilities are available including the one which you are asking for.

Very first, it has lot of shortcuts for frequently done things as, \im for including the main function. And according to the type of the file, and not for all files. And you can also include your own predefined codes, and get it using shortcuts.

Have a look at this for more clarification: c++ IDE

thegeek