Wenbin Fei bio photo

Wenbin Fei

Porous media simulation; Data anlysis; Geotechnical engineering; Reservoir engineering.

Email LinkedIn Github

Vintage mode in Sublime text provide the vim enviroment.

Enable vintage mode

In Preferences>Setting>User, add the following codes

{
	"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
	"font_size": 10,
	"ignored_packages":
	[
	],
	"theme": "Default.sublime-theme",
	"vintage_ctrl_keys": true
}

Default Ctrl key bindings in Sublime

  • Ctrl+[: Escape
  • Ctrl+R: Redo
  • Ctrl+Y: Scroll down one line
  • Ctrl+E: Scroll up one line
  • Ctrl+F: Page Down
  • Ctrl+B: Page Up

For my own convinience, I coustomerized the escape key to be jj by adding the following codes in preferences>key bindings>usr

Custom escape key, in key binding
{ "keys": ["j", "j"], "command": "exit_insert_mode",
    "context":
    [
        { "key": "setting.command_mode", "operand": false },
        { "key": "setting.is_widget", "operand": false }
    ]
}

Vim cheat sheet

Key Description
h b B ^ 0 h-previous character; b-pervious work; B-pervious work and skip punctuation; ^-first non-blank character; 0-begining of line;
l e w E W $ l-next character; e-end of word; w-begining of next word; E-end of Word; W-begining of next WORD; $-end of line
k Ctrl+u Ctrl+b gg k-up 1 line; Ctrl+u-up 1/2 page; Ctrl+b-up 1 page; gg-first line;
j Ctrl+d Ctrl+f G j-down 1 line; Ctrl+d-down 1/2 page; Ctrl+f-down 1 page; G-last line;
j Ctrl+d Ctrl+f G j-down 1 line; Ctrl+d-down 1/2 page; Ctrl+f-down 1 page; G-last line;
ngg Goto line n
Shift + * jump to next word matching cursor (case insensitive)
Shift + # jump to previous word matching cursor
Shift + H move to high (header) part of screen
Shift + M move to middle of screen
zz center screen on cursor
zt allgn top of screen on cursor
zb allgn top of center screen on cursor
Shift + L move to lower part of screen
Shift + } Go next paragraph empty space
Shift + { Go previous paragraph empty space
Shift + % Jump to open/close (), {}, or []

Bookmark

m [a-z0-9] (book)mark current cursor position with register (any key [a-z0-9])
[a-z0-9] Return to marked position [a-z0-9] (first non-blank character in line)
Ctrl + + g Find All instances
` [a-z0-9] jump to line and column of mark
Ctrl+F2 Toggle Bookmark (with indicator)
F2 Jump to Next bookmark
Shift+F2 Jump to Previous bookmark
Shift+Ctrl+F2 Clear all bookmarks

Insert mode

Key Description
s delete character under cursor
i Insert infront cursor
a Append after cursor
I Insert infront of line (tip: left shift indicates direction)
A Append after line end (tip: right shift indicates direction)
o Open newline below
O Open newline above
c Change/cut (i.e. cw = deletes word)
caw Change/cut all word
cc Change/cut entire line
ci” Change inner quote content (can be anywhere before for quotes, but has to be within for parenthses)

Selecting

Key Description
v switch into visual mode
V selects line (goes into visual mode)
vt, select until the comma
vf, select until with the comma
Vngg select current line up to line number n
Vnj select current + down n lines
Alt + F3 select all under cursor

Undo Redo

Key Description
u undo
Shift + U undo all changes to current line
Ctrl + r redo
. repeat last action

Finding

Key Description
fx find x and land on it (current line only)
Fx Jump back on x (opposite of above, current line only)
tx ‘til x but land before it (current line only)
Tx Jump back ‘til x (opposite of above, current line only)
/ enter find
* set find all word & find next
n find next, alternatively using F3
N find previous alternatively using Shift + F3
/ enter find
/ enter find
: 3,9s/oldstring.newstring/g s for substitude  
%s/oldstring.newstring/g s for substitude s for substitude  
%s/oldstring.newstring/gc s for substitude  

Delete Copy Paste

Key Description
r replace single character
x delete single character
X delete previous single character
d delete (cuts)
dd delete (cuts) entire line
D delete until the end of the line
diw delete (& copy) entire word
daw delete (& copy) entire word with trailing space
d3w delete (& copy) 3 words
(starting from wherever cursor is)
num dd deletes num lines
dit delete inner tag content
y yank (copy) selection
yiw yank (copy) the current word
yy yank entire line
p paste after cursor
P paste before cursor
d num Enter deletes num lines from current position in line to current position
(not entire line)
y num p copies line num times
register y yank to register (use :reg to view register)
register p paste from register (use :reg to view register)
“0 default register. e.g. copy a line, delete(cut) a line, paste the copied line: yy pp “0p

Format

Key Description
== auto-indent current line
« indent to left
» indent to right
~ Changes the case of current character
gu Changes the selection from upper to lower
gU Changes the selection from lower to upeer

Sublime shortcuts

General

Key Description
Ctrl + p Quick-open files by name
Ctrl + ku uppercase
Ctrl + kl lowercase
Ctrl + kt hide (fold) all tag attributes
Ctrl + k0 expand all code
Ctrl + k1 collapse/fold all 1 tab indentations
Ctrl + k2 collapse/fold all 2 tab indentations
Ctrl + kb toggle side bar
Ctrl + kv paste from history
Ctrl + kc scroll cursor to centre
Ctrl + kc scroll cursor to centre

Split window

Key Description
Shift + Alt + 2 Split view into two windows (groups)
Ctrl + 2 Jump to window 2
Shift + Ctrl + 2 Move file to group 2