In Vim how to switch quickly between .h and .cpp files with the same name?

后端 未结 6 2034
太阳男子
太阳男子 2020-12-23 16:55

Suppose I have a folder with lots of .h and .cpp files. I frequently need to do the following:

  1. open a file prefix_SomeReallyLongFileName.h,
6条回答
  •  情歌与酒
    2020-12-23 17:12

    According to the Vim wiki there are quite a few suggested ways.

    I will outline a few options from the article:

    • a.vim or FSwitch.vim plugins
    • using ctags
    • :e %<.c or :e %<.h. %< represents the current file w/o the extension
    • A quick mapping nnoremap :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,. Add this to your ~/.vimrc.

提交回复
热议问题