(Change <tt> to <code>, perhaps also minor tweak.)
Line 3:
Line 3:
|previous=1500
|previous=1500
|next=1504
|next=1504
−
|created=February 2, 2007
+
|created=2007
|complexity=basic
|complexity=basic
|author=Jerome
|author=Jerome
Line 11:
Line 11:
|category2=
|category2=
}}
}}
−
When doing a complex substitution with a regular expression, it's useful to first search for what you want to replace, to confirm that the search pattern works. Or, just press <tt>*</tt> to [[VimTip1|search for the current exact word]], followed by <tt>'''``'''</tt> (two backticks) if you want to jump back to your original word.
+
When doing a complex substitution with a regular expression, it's useful to first search for what you want to replace, to confirm that the search pattern works. Or, just press <code>*</code> to [[VimTip1|search for the current exact word]], followed by <code>'''``'''</code> (two backticks) if you want to jump back to your original word.
To do the substitute, type:
To do the substitute, type:
Line 20:
Line 20:
In this substitute, the search pattern is empty, so it will use the last search.
In this substitute, the search pattern is empty, so it will use the last search.
−
Alternately, you can press Ctrl-r followed by <tt>/</tt> to insert the last-search register (for example, you might want to edit the command before pressing Enter):
+
Alternately, you can press Ctrl-r followed by <code>/</code> to insert the last-search register (for example, you might want to edit the command before pressing Enter):
<pre>
<pre>
:%s/<c-r>//New String/g
:%s/<c-r>//New String/g
</pre>
</pre>
−
If the pattern is in a register, say the <tt>'''a'''</tt> register, you can press Ctrl-r then <tt>'''a'''</tt> to insert the contents of the register at the appropriate place in the command.
+
If the pattern is in a register, say the <code>'''a'''</code> register, you can press Ctrl-r then <code>'''a'''</code> to insert the contents of the register at the appropriate place in the command.
created 2007 · complexity basic · author Jerome · version n/a
When doing a complex substitution with a regular expression, it's useful to first search for what you want to replace, to confirm that the search pattern works. Or, just press * to search for the current exact word, followed by `` (two backticks) if you want to jump back to your original word.
To do the substitute, type:
:%s//New String/g
In this substitute, the search pattern is empty, so it will use the last search.
Alternately, you can press Ctrl-r followed by / to insert the last-search register (for example, you might want to edit the command before pressing Enter):
:%s/<c-r>//New String/g
If the pattern is in a register, say the a register, you can press Ctrl-r then a to insert the contents of the register at the appropriate place in the command.