203 private links
J'ai toujours eu des soucis avec la commande "substitution/déletion" de plusieurs lignes avec vim. J'ai maintenant compris :)
De la newsletter de "Mastering Vim Quickly" :
For most Vim commands, the default range is the current line.
This means that action performed by a command will affect only the current line.
However, you can control ranges, and in that way execute commands over the custom ranges of lines or characters in the current buffer.
For example:• :s/bad/good/g - changes all words bad to good in the current line.
• :6,11s/bad/good/g - makes the same change, but in lines 6 to 11, including 6 and 11.
• :%s/bad/good/g - makes the same change in entire file.
If line range is not specified, the substitute command will operate on the current line only, by default. As already mentioned, for most commands, the default range is . (the current line).
However, for :g (global) and :w (write) commands the default is % (all lines).Let's see a few more examples of defining range with substitute command:
range
28 description
line 28 example
:28s/bad/good/g
1 first line :1s/bad/good/g
$ last line :$s/bad/good/g
.,$ current line to end of the file :.,$s/bad/good/gThat's all for today. Next week we'll get to advanced stuff with ranges and some useful commands.