When I start vim
, I always use -s SCRIPT_FILE_NAME
option to execute additional commands. In SCRIPT_FILE_NAME
, some ex commands are written. Let COMM
denote the additional commands in the file. The problem is that COMM
is added to command history. For example, when I
- start
vim
and execute:echo
and exit with:q
- and start
vim
again
the expected contents of the command history (which can be seen via q:
) are
: 48 echo
: 49 q
but the actual contents are
: 48 echo
: 49 q
: 50 COMM1
: 51 COMM2
︙
: 60 COMM11
and this is truly annoying. (Assume COMM
consists of a hundread of commands.)
Is there any way to avoid this?
NOTE1: Because the execution order is different between commands in .vimrc
and those in SCRIPT_FILE_NAME
, I cannot move COMM
to .vimrc
. In other words, there is a reason why I use -s
option in addition to .vimrc
.
NOTE2: Of course, it is possible to execute sed
command between the first and second step above to remove the undesired lines. However, doing like this isn't elegant, I think. I wonder if there is a better solution supplied by vim
by default.
Update:
By putting all of COMM
into a function in .vimrc
and calling it from SCRIPT_FILE_NAME
, the number of items added to the history can be decreased to one. But I'd still like to decrease it to zero if I can.
:h histdel()
may help. Try to putcall histdel(':', -1)
at the end of your function.