sponsor Vim development Vim logo Vim Book Ad

switch_headers.vim : Simple switching between corresponding .h/.hpp and .c/.cpp files

 script karma  Rating 2/5, Downloaded by 821  Comments, bugs, improvements  Vim wiki

created by
Slavomir Smutny
 
script type
utility
 
description
Simply switches between .c/.cpp and .h/.hpp files, suitable for one-keystroke switching.
Order of priority when looking for corresponding files:
1) if .h file, seeks for .c first, then .cpp
2) otherwise, seeks for .h first, then .hpp
Inspired by vimtip #384. Not as complex as vimscript #31, but if you need only small amount of code ...
 
install details
Drop into ~/vimfiles/plugin
Add source ~/vimfiles/plugin/switch_headers.vim to your c.vim/cpp.vim after/syntax files
Use mapping such as:
nmap <F9> :call SwitchHeader()<cr>
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
switch_headers.vim 1.2 2006-09-01 6.0 Slavomir Smutny fixed when possibly switching from non-C/C++ file + if source is missing for header
switch_headers.vim 1.1 2006-08-31 6.0 Slavomir Smutny Added check for .hpp
switch_headers.vim 1.0 2006-08-31 6.0 Slavomir Smutny Initial upload
ip used for rating: 18.217.8.82

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github