Editing in Vim I often find myself in a situation where I want to move the position of a closing bracket.
e.g. First i type
if a == 1 then Then I realize I really wanted to have brackets around the 'a == 1' part so I go back and put a bracket in and end up with
if ()a == 1 then I'm using auto-pairs plugin so the paired bracket is correctly generated.
My question is, what is the quickest way to get this to look like:
if (a == 1) then For example currently I might
- escape
- use x to delete the second character
- f1 to move to the 1
- a to append and type ')'
It seems like there should be a way to
- escape
- move the second bracket a word forward.
xf1pwill save you a little trouble. I would strongly suggest you get out of the habit of being in input mode. That is, rather than thinking of your first step being 'escape to normal mode', think of it as being normal to be in normal mode, and using i,I,a, or A to enter insert mode only to enter text, followed by <esc> to exit insert mode.xwp.