Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickest way to switch order of comma-sparated list in Vim

Tags:

vim

Supose I have a function such as

myfunc(arg1 = whatever, arg2 = different)

I would like to transform it to

myfunc(arg2 = different, arg1 = whatever)

What is the quickest command sequence to achieve this? suppose the cursor is on the first "m". My best attempt is fadt,lpldt)%p.

like image 383
Xu Wang Avatar asked Dec 07 '25 20:12

Xu Wang


1 Answers

There is a vim plugin: vim-exchange

  • visual select arg1 = whatever
  • press Shiftx
  • visual select arg2 = different
  • press Shiftx
like image 63
kev Avatar answered Dec 11 '25 15:12

kev