I very often want to do the following or similar:
- indent all lines from previous position to current position inclusive
- repeat, repeat, repeat (to further indent the same lines)
I feel I should be able to do that by saying:
>''...
(greater-than single-quote single-quote period period period).
But it doesn't work. The first >''
successfully indents the desired lines,
but then "previous position" is lost, and each .
only indents the current line
(which is always the first of the desired lines, for some reason,
no matter whether I started at the beginning or end of the desired lines).
So, instead, my recipe for indent-and-repeat is:
'' if necessary to get to first line to be indented
ma to mark it "a"
'' to get to last line to be indented
mb to mark it "b"
>'a to indent from mark "a" to current position (mark "b")
>'b to do it again (since the >'a moved me to mark "a" for some reason)
>'b to do it again (since the >'b did *not* move me to mark "b" for some reason)
>'b to do it again
In other words, to indent the lines 4 times and retain ability to jump to previous position, I say:
''ma''mb>'a>'b>'b>'b
Instead of simply the following which doesn't work:
>''...
That is WAY more time and effort and mental burden than I would like.
An alternative workaround, still awful, and loses "previous position":
>''
look for something like "63 lines >ed 1 time", and type that number:
63>>
Is there a way to make >''...
work as I would like it to?
Perhaps by some clever rebinding of the >
key.
Requirement: >''
must indent the lines without changing the current or previous
cursor position (regardless of whether ''
refers to earlier or later in the file).
Requirement: .
must do the same, as must subsequent .
's.
>>G
>''...
indent from my current position to the previous insert position as it should (but indeed the cursor moves to the'
mark). Maybe your problem is that''
doesn't represent what you think: maybe you should precise what you consider to be "previous position". If you are familiar with the''
notation maybe the problem comes from a configuration in your vimrc or a plugin and you should test the operation withvim -u NONE
(see this)''
(singlequote singlequote) several times to verify that it goes back and forth between the two lines. Stop on the first line, so "current" is "a" on line 1, and "previous" is "b" on line 2. Type>''
which indents both lines as desired. Then type.
which further indents only the first line, as undesired.vim -u NONE
per your suggestion-- same behavior (aside from different shiftwidth)