Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

3 Answers

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
add comment

you could make a function out of that.

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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