Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I store, commands found at http://www.commandlinefu.com/commands/browse, in a text file. If I open this text file in Vim and I want to execute the command where the cursor is actually located I do copy the line with Y, switching to command mode with : and !CTRL+r* Is there a more "lazy" possibility ;)

share|improve this question
up vote 5 down vote accepted
:nmap ,x Y:!<C-R>"<C-H><CR>

Then just bang on ,x

The <C-R>" pastes the yanked text into the command-line; the <C-H> deletes the EOL character which was yanked along with the line.

share|improve this answer

I think you're asking about shell commands, but if you wanted to do Vim commands, you can read your commands into a register and then run them as macros. Registers used for recording macros and yanking text are the same.

For example: create text file with

:help recording^M

(write ^M by hitting <C-v>Enter)

with that file open, type

0"ay$

then type @a to run that command


You can save any macro like this for later.

Record macro:

qa[do some commands]q

Then put it in a file:

"ap
share|improve this answer

you could make a function out of that.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .