Apr 17, 2004 #1 olded Programmer Joined Oct 27, 1998 Messages 1,065 Location 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 Joined Jul 27, 2000 Messages 2,146 Location US :!ls vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
Apr 17, 2004 2 #3 CaKiwi Programmer Joined Apr 8, 2001 Messages 1,294 Location 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 Joined Jul 27, 2000 Messages 2,146 Location US nice one, CaKiwi! vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
nice one, CaKiwi! vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Apr 18, 2004 #5 CaKiwi Programmer Joined Apr 8, 2001 Messages 1,294 Location 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 Joined Oct 27, 1998 Messages 1,065 Location US Thanks guys! Sorry I really posted this question ikn the wrong forum. Regards, Ed Upvote 0 Downvote
Apr 21, 2004 #7 bigoldbulldog Programmer Joined Feb 26, 2002 Messages 286 Location 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