Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you insert a vertical column of text in Sublime Text 2 using the vim key bindings?

How do you insert a vertical column of text and indent it in Sublime Text 2 using the vim key bindings?

Vertical Text Selection in Vim
(source: yannesposito.com)

I have seen the Sublime Text 2 Column Selection Docs, showing how you can use Ctrl + Shift + Up, but is it possible to do the same thing using the vim shortcut?

I am using Sublime in Vintage Mode.

like image 222
Lance Avatar asked May 23 '12 20:05

Lance


1 Answers

It's a bit fiddly and an extra keystroke, but it is possible: you just have to split the selection into multiple cursors before you do the standard VIM Shift+I

So the whole routine (on a Mac) is:

  1. Select block with V/v + motion keys

  2. CommandShift + L

  3. V/v to exit visual mode

  4. Multiple cursors that you can move, insert, whatever!


Alternatively, you can do what I did and adopt a hybrid approach by changing Sublime's Shift + Control + arrow keybindings to be Shift + Control + motion keys instead.

[
    { "keys": ["ctrl+shift+j"], "command": "select_lines", "args": {"forward": true} },
    { "keys": ["ctrl+shift+k"], "command": "select_lines", "args": {"forward": false} }
]

Shift + Control + K conflicts with OS X's built-in "kill all lines" binding, but ST bindings override those, and you shouldn't be using that one anyway... it's from Emacs ;)

like image 141
John Rork Avatar answered Sep 18 '22 12:09

John Rork