Created
April 2, 2012 10:17
-
-
Save bulain/2282383 to your computer and use it in GitHub Desktop.
vim command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#replace in vim | |
[addr]s/src/dist/[option] | |
addr: the range | |
nothing Work on current line only. | |
number Work on the line whose number you give. | |
% The whole file. | |
option: the arguments | |
g Replace all occurrences in the line. Without this, Vim replaces only the first occurrences in each line. | |
i Ignore case for the search pattern. | |
I Don't ignore case. | |
c Confirm each substitution. You can type y to substitute this match, n to skip this match, a to substitute this and all the remaining matches ("Yes to all"), and q to quit substitution. | |
ex: | |
s/foo/bar/g replace foo with bar for current line | |
%s/foo/bar/g replace foo with bar for whole file | |
%s/foo/bar/gi replace foo with bar for whole file with ignore case | |
%s/foo/bar/gc replace foo with bar for whole file with confirm | |
1,$s/foo/bar/g replace foo with bar for while file | |
1,5s/foo/bar/g replace foo with bar from line 1 to line 5 | |
.,5s/foo/bar/g replace foo with bar from current line to next 5 line | |
5,$s/foo/bar/g replace foo with bar from line 5 to end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment