Tuesday 28 August 2012

VI editor tricks

Word count


http://vim.wikia.com/wiki/Word_count

find text, then replace part of text

There is another form of line addressing called global addressing. It is similar to the % (all lines) address, but allows you to limit the search and replace action by specifying certain text that must appear in a line before the search and replace action is applied to it. An example is show below. The syntax shown below would read "for all lines containing `some text', search for `search text' and replace any instances with `replacement text.'"

:g/some text/s/search text/replacement text/

other stuff


:%s/test/mytest/gIc

arguments g=global, I=dont ignore case, c=confirmation required

regex

:%s/[A-Z]', '2'//gn

count occurences of: letter then comma then space then apostrophe then 2 apostrophe


No comments:

Post a Comment