问题
Say I have a class evilLord
declared in the file evil_lair.hh
and is implemented in the file evil_lair.cc
. Now, I want to add the function bool minionDo(std::string command)
. Is there any script which will put the declaration and empty function definition in the respective files automatically?
I am using c-support
vim-plugin which I find useful. Maybe this can be added as a functionality to this script...
回答1:
The task is not that trivial -- if we want to correctly report the scope of the function. I've already done the work in my :GOTOIMPL
(and :MOVEIMPL
) command, from my lh-cpp ftplugin suite.
回答2:
Here is a script which will work:
:let lines = ["bool minionDo(std::string command)"]
:e evil_lair.hh
:call append( line('$'), lines )
:wq
:e evil_lair.cc
:call append( line('$'), lines )
:call append( line('$'), "{}" )
:wq
来源:https://stackoverflow.com/questions/8844817/vim-script-for-automatic-function-insertion