> Does anyone know if there are any builtin commands to rotate
> the current line about a character or word?
> 
> I know it would be pretty easy to do these with macros, but I
> thought there might be some builtin or something.

There's nothing built-in, but you can map something of the like:

> rotate about the j and just respectively
> 'This is just a test ' becomes 'ust a testj This is'

According to your description of what "rotating" should do,
rotating around the "j" in this example would yield

        'ust a test jThis is '

rather than

        'ust a testj This is'

but can be done with

:nnoremap gw :s/^\(.*\)\%#\(.\)\(.*\)$/\3[\2]\1<cr>

> 'This is just a test' becomes 'a test just This is'

This can be done with:

:nnoremap gW :s/^\(.\{-}\)\(\s*\<\w*\%#\w*\s*\)\(.*\)$/\3\2\1<cr>

Though somewhat funky things happen if you're in whitespace
rather than over Word characters.

I don't recall if the "\%#" was added in Vim7 or if it works in
prior versions.  YMMV.

HTH,

-tim






Reply via email to