I have the following configuration in my .vimrc file to switch between a .c File and it's corresponding .h File
function SwitchHeader()
w
if(&ft=='cpp')
e %:r.c
elseif(&ft=='c')
e%:r.h
endif
endfunction
When i enter :call SwitchHeader()
into the vim command line
The message appears Bestätigen sie die EINGABETASTE oder geben sie einen Befehl ein
which i would translate to Hit the enter key or enter a command
How can i avoid having to press enter every time i call the function, when i bind key i can use <cr>
at the end of the line to insert an Enter, but how can do this in the function.
~/enter.vim
, created three files,enter.cpp
, 'enter.c` andenter.h
, and executedvim -N -u NONE --cmd 'filetype on' -c 'so ~/enter.vim' enter.cpp
. Then executing:call SwitchHeader()
switches between those files, but there is no "Hit Enter" message. So I don't see the problem. You might take a look at:help hit-enter-prompt
and see if that provides a clue.:write
and:edit
commands with:silent
.:silent :write
,:silent :edit ...
, etc.