derekwyatt / vim-fswitch

Vim plug for switching between companion source files (e.g. ".h" and ".cpp")
179 stars 57 forks source link

This pull request improves the autocmd for C/C++ source files and header files #3

Closed xuhdev closed 12 years ago

xuhdev commented 12 years ago

Add the support of .hpp, .hxx, .H, .cxx, *.C. They are all commonly used.

derekwyatt commented 12 years ago

This won't work very well. If you have a .hxx file, then a .cpp file will be created if there is no match (i.e. you don't have a .cxx file). These should be separate rules - i.e. one for .cxx, one for .C, etc...

xuhdev commented 12 years ago

What about this one?

au BufEnter *.h,*.hpp call s:SetVariables('cpp,cxx,C,c', 'reg:/include/src/,reg:/include.*/src/,ifrel:|/include/|../src|')
au BufEnter *.hxx     call s:SetVariables('cxx,c,C,cpp', 'reg:/include/src/,reg:/include.*/src/,ifrel:|/include/|../src|')
au BufEnter *.H       call s:SetVariables('C,c,cpp,cxx', 'reg:/include/src/,reg:/include.*/src/,ifrel:|/include/|../src|')
au BufEnter *.c,*.cpp call s:SetVariables('h,H,hpp,hxx', 'reg:/src/include/,reg:|src|include/**|,ifrel:|/src/|../include|')
au BufEnter *.cxx     call s:SetVariables('hxx,h,H,hpp', 'reg:/src/include/,reg:|src|include/**|,ifrel:|/src/|../include|')
au BufEnter *.C       call s:SetVariables('H,h,hpp,hxx', 'reg:/src/include/,reg:|src|include/**|,ifrel:|/src/|../include|')
derekwyatt commented 12 years ago

If you let me make some modifications, I'll pull this in.

Essentially, what I'd do is:

That's it. What you've got above is far to "mix and match" kind of stuff, that doesn't help anyone really code to any internal standard. I think this tool should help people keep their standards, out of the box. If they want to do something "weird" then they can customize after that.

xuhdev commented 12 years ago

OK. That would be fine

derekwyatt commented 12 years ago

Ok, I'm going to close this merge request and just submit it as a new change.

xuhdev commented 12 years ago

A suggestion:

cxx maps to hxx, h h maps to cpp, cxx, c

Since many people use h and cxx instead of cpp.

derekwyatt commented 12 years ago

I disagree. I think cxx is the devil - stupid extension - and after 18 years of C++ development, I have /never/ encountered in a real project. cxx is out. cpp is the most common extension by far... in general, I follow the Boost conventions as law in most cases.