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 thi开发者_开发百科ng?
: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
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>!
:<up><home><right>!
?
The easiest way I know offhand is to hit ESC :
and then use history (either ^p
or up-arrow) to get at your previous command again. Ironically editing within that buffer is more emacs-like than vi-like.
You could actually bind this to a key with :map ! :^[OA^[[1~^[OC!^M
(each of those escape characters and the ^M need to be actual escape characters -- you can get them by typing ^V
first)
精彩评论