ViM - Swap sides: LHS <-> RHS
Swap Left Hand Side with Right Hand Side in ViM!
Example:
Input:
a [ 2 + x ] -= b [index-stride*8];
Output:
b [index-stride*8] -= a [ 2 + x ] ;
ViM command:
:s/\([ ]*\)\([^=^\t]*\)\([+-/* ]=\) \([^;^\t]*\);/\1\4 \3 \2;
Remmaping to F2:
noremap <F2> :s/\([ ]*\)\([^=^\t]*\)\([+-/* ]=\) \([^;^\t]*\);/\1\4 \3 \2;<CR>:nohl<CR>
Written by Guilherme Alcarde Gallo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#