Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send current line to external command in vim (without capture)

Tags:

vim

The goal is to use the current line as a TODO and send this to some external program. Something like this:

:! /usr/bin/todo "content of current line" 

I know of the filtering command but this implies that I want to edit the current buffer which I do not want (:.! acts as a filter). I know how to get the current file with '%' but isn't there any way to get some other content ? Maybe by using :execute ...

like image 335
Anna B Avatar asked Aug 11 '11 09:08

Anna B


People also ask

What key do you press to enter command line mode in Vim?

To go back to COMMAND mode, you type the esc key. vim starts out in COMMAND mode. Over time, you will likely spend more time in COMMAND mode than INSERT mode. Note that all commands mentioned below (except for arrow keys) only work in COMMAND mode.

What is the Vim command to save changes with a filename you specify?

The command to save a file in Vim is :w . To save the file without exiting the editor, switch back to normal mode by pressing Esc , type :w and hit Enter . There is also an update command :up , which writes the buffer to the file only if there are unsaved changes.


1 Answers

:.! works as a filter, but :.w ! (mind the space!) just passes the output. See :help :w_c. I.e.

:.w !/usr/bin/todo - 
like image 198
Jan Hudec Avatar answered Sep 18 '22 17:09

Jan Hudec