I'm looking for a fast and efficient way to re-use the parameters of the last command in a new command. For example, in a Bash shell you can use the $1
placeholder to reuse the 1st argument of the last command, $!
to reuse the last argument, etc. In a Fish shell you can use Alt-Up and Alt-Down keys to bring up the parameters of the complete history.
A regular use case is that I want to re-use parts of a file name I used in a previous command. If the file is still open, I could use Ctrl-R, % in the command line, but if I switched files, I have to open the command history, look for the command and copy the file name.
Ideally, I'd like to have an autocomplete-like key binding in the command line that allows me to skip though parts of the history just like I would skip through file names when hitting Tab.
q:k
and start editing the previous commandq:
and it's a bit of a game-changer.q:
andh k j l
are hard to beat. Don't be afraid to:q
to escape back to Normal Mode afterq:
. I feel that's what has people shying away fromq
commands in general (fear of quitting out of Vim entirely). @D.BenKnobleq:
has already been mentioned. Besides that, there is also:<C-N>
,:<C-P>
, and:<C-F>
.