2009-11-25

Ranges in vim

I hadn't used ranges in vim (other than % -- the whole file) until now. Thought it was about time I found out how to use them.

. is the current line, $ is the last line. Numbers mean that line so 1 is the first line in the file. That's the most important stuff -- the full list is at :he range.

They can be followed with + or - which adds or takes one from the line number, or the plus or minus can be followed with a number to add or subtract that many.

Ranges can be just one line or from,to. So the range I need to use right now, current line until the end of the file, is .,$ and so to do my replacement I type :.,$s/"#ffbaba"/errorcolour/g.

No comments:

Post a Comment