简体   繁体   中英

Repeat last command with an exclamation? 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?

:e! #

指定vim文件时, %是当前文件的快捷方式, #是“previous”(实际上更像是“other”)文件的快捷方式,在你的情况下是~/.../bar.rhtml

q:将显示历史记录,您可以直接编辑命令,然后按Enter键再次运行它们,或者您可以按照zigdon的建议进行操作:<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 :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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM