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 ;)

link|improve this question
feedback

3 Answers

up vote 4 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.

link|improve this answer
feedback

you could make a function out of that.

link|improve this answer
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.