VIM作为VIM命令执行当前行

时间:2018-05-05 23:02:35

标签: vim command

是否可以在由 VIM 打开的文本文件中执行 VIM 命令?例如,我们可以使用以下文本,我们希望在不键入的情况下执行:help w

  Read the text in the help window to find out how the help works.
  Type  CTRL-W CTRL-W   to jump from one window to another.
  Type    :q <ENTER>    to close the help window.

  You can find help on just about any subject, by giving an argument to the
  ":help" command.  Try these (don't forget pressing <ENTER>):

    :help w
    :help c_CTRL-D
    :help insert-index
    :help user-manual

1 个答案:

答案 0 :(得分:4)

您可以创建以下映射来执行当前行中定义的命令:

nnoremap <c-e> :exe getline('.')<cr>

将光标放在:help w的行中并输入Ctrl+E将打开帮助页面。