At the moment I am most passionate about politics, robotics and linux. So if you like any of this stuff come and read!!!

Wednesday, April 6, 2011

Vim Visual Selection Tricks

# VISUAL SELECTION TRICKS:# You can use filters and vim's execution mode.to do some powerful things.# A filter is any standard UNIX program (sort, awk, grep, cut, paste, sed ...) that can read from stdin and write to stdout.# Vim's execution mode lets you read in or replace text with the output of a program. If you make a visual selection (say,# using V or C-V), and hit :, your command prompt will immediately be :'<,'>, which means "Apply whatever command follows# to the lines included in the visual selection." At this point, you can write !foo to replace the text with the output of# program foo.

# For example, to sort the text by the python column, select it, hit :, and enter !sort -k5. The whole command will look like :'<,'>!sort -k5# Running it will produce: