Vim Tips Wiki
Register
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 4: Line 4:
 
|previous=427
 
|previous=427
 
|next=431
 
|next=431
|created=2003
+
|created=February 18, 2003
 
|complexity=basic
 
|complexity=basic
 
|author=Dubhead
 
|author=Dubhead
Line 55: Line 55:
 
* works at the beginning of a line
 
* works at the beginning of a line
 
* terminates at the end of a line (doesn't do anything weird)
 
* terminates at the end of a line (doesn't do anything weird)
* doesn't overwrite the unnamed (last used) register <code>@"</code>
+
* doesn't overwrite the unnamed (last used) register <tt>@"</tt>
   
 
<pre>
 
<pre>
Line 67: Line 67:
 
What it does:
 
What it does:
   
# Cancel insert mode and save <code>@"</code> to <code>@z</code>. This macro will overwrite register z and mark z. Use temporary ones that you would never use manually.
+
# Cancel insert mode and save <tt>@"</tt> to <tt>@z</tt>. This macro will overwrite register z and mark z. Use temporary ones that you would never use manually.
 
# Mark position z.
 
# Mark position z.
 
# Move up, and then move right only if the cursor was not at the beginning of the line on an empty line.
 
# Move up, and then move right only if the cursor was not at the beginning of the line on an empty line.
# If the cursor is now at the end of the line, do nothing (and clear <code>@"</code> so the paste doesn't duplicate the last paste). Otherwise yank to the next word.
+
# If the cursor is now at the end of the line, do nothing (and clear <tt>@"</tt> so the paste doesn't duplicate the last paste). Otherwise yank to the next word.
 
# Go back to mark z and paste.
 
# Go back to mark z and paste.
# Restore <code>@"</code> and go into insert mode after the pasted text.
+
# Restore <tt>@"</tt> and go into insert mode after the pasted text.
   
 
You can also change the mapping to yank to the end of a word (change "yw" to "ye" on the third line).
 
You can also change the mapping to yank to the end of a word (change "yw" to "ye" on the third line).
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)