The plugin transwrd.vim allows to to easily swap two words by pressing <A-t> while having cursor on the latter word.For example:  two words becomes words two.I think the pattern which designates a word is contained in the g:transwrd_wordpattern variable and is (as default) the following: \k\+Is it possible to define an advanced pattern which allows to be more programming language savvy (while still working for normal words)? Eg.param[0], param[1]  -->  param[1], param[0]int call1()         -->  call1() intThis way it could also be used to swap function arguments (related to this other question).
Programming-oriented word swap using transwrd.vim
regular expression
Yes, if you can come up with a regular expression that will, alone, capture everything you consider to be a word. The plugin uses the pattern stored in g:transwrd_wordpattern to identify words by finding two matches and then swapping the characters in the matched ranges.Doing let g:transwrd_wordpattern='[a-zA-Z0-9\[\]\(\)]\+' will, for example, let it match both of your examples.