Skip to content

Instantly share code, notes, and snippets.

View soto97's full-sized avatar

Alejandro Soto soto97

View GitHub Profile
search and replace
-------------------
s/foo/bar/g changes each 'foo' to 'bar' in the current line.
:%s/foo/bar/g changes each 'foo' to 'bar' in all lines.
:5,12s/foo/bar/g changes each 'foo' to 'bar' for all lines between line 5 and line 12.
:'a,'bs/foo/bar/g changes each 'foo' to 'bar' for all lines between marks a and b.
:.,$s/foo/bar/g changes each 'foo' to 'bar' for all lines between the current line (.) and the last line ($).
:.,+2s/foo/bar/g changes each 'foo' to 'bar' for the current line (.) and the two next lines (+2).
:%s is equivalent to :1,$s