Created
May 17, 2020 11:22
-
-
Save faustaleonardo/910cec26544a59e570dd53d99e3ce9fa to your computer and use it in GitHub Desktop.
Handy Vim Shortcuts in VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Explorer | |
ctrl + w + h = move to the file explorer. Then, use l to open the file. | |
cmd + shift + p or cmd + shift + x = type anything. Then + tab and + j to move up or + k to move down. | |
// Word | |
w = move forward to the first character of a word | |
W = move forward to the first character of a word ignoring special characters | |
b = move backwards to the first character of a word | |
B = move backwards to the first character of a word ignoring special characters | |
e = move forward to the end char of the word | |
ge = move backwards to the end of character of a word | |
// New Line | |
o = open new line on the bottom | |
O = open new line on the top | |
// Find Character | |
f + any character = move quickly to the found character forwardly. Work in one line | |
Then type ; to move to the next or , to go the previous | |
F + any character = move quickly to the found character backwardly. Also work in one line | |
t + any character = move quickly to anything just before the character | |
// Move Faster Horizontally | |
^ = move to the beginning in a line | |
$ = move to the end in a line | |
// Move Faster Vertically | |
{ = move down per paragraph | |
} = move up per paragraph | |
ctrl + d = another way to move down | |
ctrl + u = another way to move up | |
any number + k = to move down, any number + j = to move up. Normally, 5. | |
hold k to move down or hold j to move up | |
// My custom mappings (settings.json in VS Code) | |
"vim.leader": "<Space>", | |
"vim.insertModeKeyBindings": [ | |
{ | |
"before": [ | |
"j", | |
"j" | |
], | |
"after": [ | |
"<Esc>" | |
] | |
} | |
], | |
"vim.normalModeKeyBindingsNonRecursive": [ | |
{ | |
"before": [ | |
"J" | |
], | |
"after": [ | |
"5", | |
"j" | |
] | |
}, | |
{ | |
"before": [ | |
"<leader>", | |
"j" | |
], | |
"after": [ | |
"J" | |
] | |
}, | |
{ | |
"before": [ | |
"K" | |
], | |
"after": [ | |
"5", | |
"k" | |
] | |
}, | |
{ | |
"before": [ | |
"<leader>", | |
"k" | |
], | |
"after": [ | |
"K" | |
] | |
}, | |
{ | |
"before": [ | |
"<Leader>", | |
"/" | |
], | |
"commands": [ | |
":noh" | |
] | |
}, | |
], | |
"editor.lineNumbers": "relative" | |
// Search Word | |
/ + any word + enter = search word forwardly. Then + n to go to the next or + N to go to the previous. | |
? + any word + enter = search word backwardly. | |
:nohl = remove the highlight | |
/word = find word and Word | |
/Word = find only Word | |
/\Cword = find only word (precise) | |
// Move fast around a project | |
cmd + p + type abbreviation. For instance, shEn for shipEntity.js | |
When we have import app from 'App.css'. Move the cursor to App.css, type gf to open the file. | |
Or when we have import * as serviceWorker from './servicerWorker'. Move the cursor to serviceWorker, type gd to see the definition. | |
// Combine count + motion to move even faster - {count}{motion}. E.g: | |
2fe = find the second character of 'e' | |
5j = move 5 down | |
// Vim Operator | |
dw = delete until the next word | |
db = delete until the beginning of the previous word | |
d{ = delete until next paragraph | |
dt( = delete until next parentheses | |
cw = change until the next word | |
cb = change until the beginning of the previous word | |
// Text Objects (inner = delete what is needed, around = delete what is needed and around it including whitespace) | |
ciw = change inner word, delete the word. Change to insertion mode | |
caw = change around word, delete the word and around it. Change to insertion mode | |
ci" = change inside quotes | |
dap = delete a paragraph | |
d2ap = delete two paragraphs | |
ciB = delete a block. Usually inside a curly braces | |
// Good to know. Alternative to multiple cursors | |
1. search word using / | |
2. ciw | |
3. change vim to normal mode | |
4. type n and type . | |
5. the word is replaced |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment