Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat last command with an exclamation? Vim

Tags:

vim

When I've just typed a huge command such as:

:e ~/Projects/foo/app/views/bar.rhtml

Vim inevitably tells me that I haven't saved the current buffer. Is there a quick way to repeat the command with an exclamation point, without having to retype the whole thing?

like image 384
brian Avatar asked Nov 01 '10 06:11

brian


2 Answers

:e! #

When specifying vim files, % is a shortcut to the current file and # is a shortcut to the "previous" (really, more like "other") file, which in your case is ~/.../bar.rhtml

like image 157
DigitalRoss Avatar answered Sep 17 '22 18:09

DigitalRoss


q: will bring up the history and you can edit the commands directly and then hit enter to run them again, or you can do as zigdon suggested and :<up><home><right>!

like image 20
OmnipotentEntity Avatar answered Sep 17 '22 18:09

OmnipotentEntity