Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a.vim for C++

is there a way to use the a.vim plugin to switch between .h, .cxx and .txx files? Alternatively, can you provide another solution? The idea is to automagically switch from .h -> .txx -> .cxx at the press of a key.

A Big Thanks to both of you!

like image 637
static_rtti Avatar asked Feb 03 '10 13:02

static_rtti


People also ask

Is vim good for c?

It is said that vim is not suitable for C/C++, especially big C/C++ projects. and the best way to write C/C++ is to use an IDE like qt-creator , clion or vs.

What is Vim in c?

Vim is a well-known and mature text editor that is highly efficient at editing code. It is often referred to as a “Programmer's editor” but in practice, it can be used for all kinds of text editing.

Can I write C++ in Vim?

Vim (vi improved) is a text editor, in which you can create and modify your code (be it C++, Java, shell scripts, grocery lists - whatever text files you care to edit).

Is vim better than Vscode?

Personally I'd say VS Code. If you aren't already used to VIM, you'll find VS Code much easier to use and hence you will be more productive. If you want to really take the time to get used to it, then VIM can be customized to do what you want. That's my thinking if you're trying to write a lot of code.


1 Answers

Look for the lines in a.vim that contain AddAlternateExtensionMapping. The first argument is the extension of the current file, the second is a list of extensions of the file you'd like to switch to with :A. They are listed in order of preference. In your case, you'd have to set it up so that it would go in a cycle.

call <SID>AddAlternateExtensionMapping('h', 'txx,cxx')
call <SID>AddAlternateExtensionMapping('txx', 'cxx,h')
call <SID>AddAlternateExtensionMapping('cxx', 'h,txx')

So now you go from .h to .txx if it exists or .cxx if it doesn't.

like image 81
Michael Kristofik Avatar answered Oct 02 '22 05:10

Michael Kristofik