I currently use the A.vim plugin to swap between header and implementation file. The limitation of this script is that it only works if both are in the same folder.
If you have a cscope database for your code you can easily find the header for a particular implementation file by doing :cscope find f ImplementationFileName.h
.
How would you script this to take the current file name without the extension and search for that name with the added .h suffix?
This should be possible out of the box using A.vim. Check out :help alternate-config. Specifically the section on search paths:
b) Search Paths: In many projects the
location of the source files and the
corresponding header files is not
always the same directory. This plugin
allows the search path it uses to
locate source and header files to be
configured. The search path is
specified by setting the
g:alternateSearchPath variable. The
default setting is as follows,
g:alternateSearchPath =
'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
This indicates that the corresponding
file will be searched for in
../source, ../src. ../include and
../inc all relative to the current
file being switched from. The value of
the g:alternateSearchPath variable is
simply a comma separated list of
prefixes and directories. The "sfr:"
prefix indicates that the path is
relative to the file. Other prefixes
are "wdr:" which indicates that the
directory is relative to the current
working directory and "abs:" which
indicates the path is absolute. If no
prefix is specified "sfr:" is assumed.