Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm new to Vim bindings and I want to start using them in Sublime, but ran into a few stumbling blocks.

When I type various kinds of enclosed tokens, such as "string literals" or {code blocks} or (parens) I have developed the (good?) habit of typing the opening and closing characters, tapping back, and filling in the desired characters. I do this so I never forget closing characters.

For example, to produce "literal", I would type "" then move the cursor back 1 space, then write the word literal inside the quotes, then move the cursor 1 space forward to continue typing.

With Vim bindings, I seem to have to leave Insert mode each time I move back a space and then forward a space. Sublime has some settings that will automatically type () whenever you type ( and then place the cursor in the middle, so I guess that eliminates the need for the first move, but the problem of moving the cursor forward after typing my enclosed statement remains.

Vim users must have some good approach to this or they would all have gone mad by now. Do you guys just give up at typing the opening and closing characters first? Fancy key bindings to leave insert mode, move forward/back by 1, and then go back to insert mode (I would want this in one keypress)??

Please let me know if I'm doing this all wrong and also if you have a better title suggestion. Wasn't sure how to describe this problem.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

In sublime you can edit the mappings to do something like "shift+space" to move the cursor forward one space using the following code as seen here: http://stackoverflow.com/questions/14800608/sublime-text-2-move-cursor-out-of-parenthesis-quotes-or-brackets

{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} }

Works fantastic for me.

Edit: This will make ctrl+shift+space move backwards one space.

{"keys": ["ctrl+shift+space"], "command": "move", "args": {"by": "characters", "forward": false} }

The combination of the two makes life much easier :)

share|improve this answer

Vim has numerous smart "auto close" plugins and it's easy to come up with your own simple mappings like inoremap () ()<Left>.

But, both in Vim and in Sublime, you can simply type () and hit <Left>. It's certainly not as embarrassing as exiting insert mode just to go back one character.

share|improve this answer
    
yes, just hitting the left arrow would be another option of course. I disabled arrow keys to force myself to use hjkl, but might revert that to make life easier here :) –  fractalous Feb 20 at 9:40
    
hjkl are not better than the arrows, don't let "them" brainwash you. –  romainl Feb 20 at 9:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.