> Is there a way to take a line from the editing buffer and then execute
> it or source it.
> For example, I was going through a textfile where several linux
> commands were written. Now since I am lazy :), I don't like to go to
> insert mode, then copy that line, then enter exec mode, and then paste
> and then press enter. Oh Man its too tedious!!

Heh, lazy after my own heart.

If they are Ex commands, and have the leading colon, you can just 
yank them and then execute them as a macro:

Highlight these two lines:

""""""""""""""""""""""""""""""""
:%s/foo/bar/g
:%s/fred/barney/g
""""""""""""""""""""""""""""""""

and yank them.  Then execute them with

   @"

(or, if you yanked to a named register with "ay then you can 
playback with @a instead).  I actually use this method quite a 
bit to create huge search/replace pairs (usually from a 
tab-delimited source file) into a huge list of Ex statement like 
above.  I then just issue ":%y" to yank the whole result and then 
@" to execute it in another window.

If they don't have leading colons, then it may be fastest to just 
use blockwise visual-mode to add 'em.

If they are normal mode commands, having them on multiple lines 
isn't a very clean way to use them.  However, you can yank the 
selection of them and then execute that as a macro.

Either way, the game is the same, and could be automated 
something like

   :nnoremap <f4> ^y$@"
   :vnoremap <f4> y@"

-tim





--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to