简体   繁体   English

Vim-每种语言的Ab

[英]Vim - ab for each language

I try to write :ab in Vim for faster coding but the question is can I write ab for each language . 我尝试在Vim中写:ab以获得更快的编码,但是问题是我可以为每种语言写ab吗。

Like in HTML : I write begincode : I'll be HTML DOC TYPE 就像在HTML中一样:我编写begincode:我将成为HTML DOC TYPE

in C++ : It'll be int main () { return 1; 在C ++中:它将是int main(){return 1; }; };

I'm a new beginner in Vim and I miss intellisense in visual studio, can I have it in Vim . 我是Vim的新手,我想念Visual Studio中的intellisense,可以在Vim中使用它吗? I mean not only for C++, but another language too :) 我的意思是不仅对于C ++,而且对于另一种语言也是如此:)

Thanks for reading . 谢谢阅读 。

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 . 在文档中有关于此类型的完整部分:help ftplugin in vim或在线查看 The ftplugins are named after the filetype they run for, for example cpp.vim for C++ code. ftplugins以它们运行的​​文件类型命名,例如对于C ++代码为cpp.vim

If this is just for you, you can place your filetype plugin in ~/.vim/ftplugin . 如果这只适合您,则可以将文件类型插件放在~/.vim/ftplugin For a example, for ~/.vim/ftplugin/cpp.vim you could write: 例如,对于~/.vim/ftplugin/cpp.vim您可以编写:

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 (eg vim72 for Vim 7.2). 如果您有兴趣,可以在vim安装的ftplugin目录中看到所有内置的文件类型插件-在大多数系统上,即/usr/share/vim/vimXX/ftplugin ,其中vimXX是vim版本(例如Vim的vim72) 7.2)。 If you have any additional ones installed system-wide, they'd be in /usr/share/vim/vimfiles/ftplugin . 如果您在系统范围内安装了其他安装,则它们将位于/usr/share/vim/vimfiles/ftplugin

Instead of going for your own file type plugin, i would strongly recommend c.vim plugin for you. 我强烈建议您使用c.vim插件,而不是使用您自己的文件类型插件。 That is one of the largely used vim plugin, where a lot of facilities are available including the one which you are asking for. 这是使用最广泛的vim插件之一,其中提供了许多功能,包括您所要求的功能。

Very first, it has lot of shortcuts for frequently done things as, \\im for including the main function. 首先,它为常用的事情提供了许多快捷方式,例如\\ im包括主要功能。 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 对此进行进一步说明: c ++ IDE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM