Apr 17, 2004 #1 olded Programmer Oct 27, 1998 1,065 US Hi: I seem to remember being able from within vi being able to execute an external command, and have the results of that command appear in vi. Does anybody no how to do this. Regards, Ed
Hi: I seem to remember being able from within vi being able to execute an external command, and have the results of that command appear in vi. Does anybody no how to do this. Regards, Ed
Apr 17, 2004 #2 vgersh99 Programmer Jul 27, 2000 2,146 US :!ls vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
Apr 17, 2004 2 #3 CaKiwi Programmer Apr 8, 2001 1,294 US Or to insert the output of a command into your file :r !ls You can also send part of your file to a command and replace that text with the output of the command e.g. to format the current paragraph !)fmt This sends the rest of the current paragraph to the fmt command and replaces that paragraph with the output from the fmt command CaKiwi Upvote 0 Downvote
Or to insert the output of a command into your file :r !ls You can also send part of your file to a command and replace that text with the output of the command e.g. to format the current paragraph !)fmt This sends the rest of the current paragraph to the fmt command and replaces that paragraph with the output from the fmt command CaKiwi
Apr 17, 2004 #4 vgersh99 Programmer Jul 27, 2000 2,146 US nice one, CaKiwi! vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
nice one, CaKiwi! vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Apr 18, 2004 #5 CaKiwi Programmer Apr 8, 2001 1,294 US Thanks Vlad! A minor errorin my post - !)fmt formats the current sentence, !}fmt is needed to format the current paragraph CaKiwi Upvote 0 Downvote
Thanks Vlad! A minor errorin my post - !)fmt formats the current sentence, !}fmt is needed to format the current paragraph CaKiwi
Apr 18, 2004 Thread starter #6 olded Programmer Oct 27, 1998 1,065 US Thanks guys! Sorry I really posted this question ikn the wrong forum. Regards, Ed Upvote 0 Downvote
Apr 21, 2004 #7 bigoldbulldog Programmer Feb 26, 2002 286 US I often grab some range or the entire body within vi and apply shell stuff to it. e.g. # keep 2 of pipe-delimited columns :/start/,/end/!awk 'BEGIN{FS=OFS="|"}{print $2,$3}' # or :%!cut -d"|" -f2,3 # add 5 to each of list of values :%!while read value; do expr $value + 5; done etc... Mostly I use this with the sort command on ascii dumps of data. Cheers, ND bigoldbulldog@hotmail.com Upvote 0 Downvote
I often grab some range or the entire body within vi and apply shell stuff to it. e.g. # keep 2 of pipe-delimited columns :/start/,/end/!awk 'BEGIN{FS=OFS="|"}{print $2,$3}' # or :%!cut -d"|" -f2,3 # add 5 to each of list of values :%!while read value; do expr $value + 5; done etc... Mostly I use this with the sort command on ascii dumps of data. Cheers, ND bigoldbulldog@hotmail.com