Wikia

Vim Tips Wiki

Changes: Swap LHS and RHS of an Assignment statement

Edit

Back to page

(Insert subpage argument (where new tip discussed))
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 3: Line 3:
 
|previous=1505
 
|previous=1505
 
|next=1507
 
|next=1507
|created=June 6, 2007
+
|created=2007
 
|complexity=basic
 
|complexity=basic
 
|author=Mike Brotherston
 
|author=Mike Brotherston
Line 28: Line 28:
 
<C-S> may cause Unix terminals to suspend. Replace with <F2> or something easy to remember for your own purposes.
 
<C-S> may cause Unix terminals to suspend. Replace with <F2> or something easy to remember for your own purposes.
   
This mucks with your current matched highlighting selections; thus the trailing <tt>:nohl</tt>. If someone knows how to do this without mucking with the incremental searches jot it down.
+
This mucks with your current matched highlighting selections; thus the trailing <code>:nohl</code>. If someone knows how to do this without mucking with the incremental searches jot it down.
   
 
==Comments==
 
==Comments==

Latest revision as of 06:27, July 13, 2012

Tip 1506 Printable Monobook Previous Next

created 2007 · complexity basic · author Mike Brotherston · version 7.0


Suppose you have a statement (C/C++/Java/etc):

alpha = beta;

and you want to change it to:

beta = alpha;

Try this mapping:

noremap <C-S> :s/\([^ =]*\)\([ ]*\)=[ ]*\([^;]*\);/\3 = \1;/<CR>:nohl<CR>

<C-S> may cause Unix terminals to suspend. Replace with <F2> or something easy to remember for your own purposes.

This mucks with your current matched highlighting selections; thus the trailing :nohl. If someone knows how to do this without mucking with the incremental searches jot it down.

CommentsEdit

Around Wikia's network

Random Wiki