Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM executing current line as VIM command

Tags:

command

vim

Is it possible to execute a VIM command inside a text file that is opened by VIM? For example we can have the following text and we would like to execute :help w without typing it.

  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
like image 545
Vesnog Avatar asked May 22 '26 13:05

Vesnog


1 Answers

You could create the following map to execute the command defined in the current line:

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

Placing the cursor in the line with :help w and typing Ctrl+E will open the help page.

like image 92
builder-7000 Avatar answered May 25 '26 08:05

builder-7000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!