Skip to content

Instantly share code, notes, and snippets.

@hochun836
Last active September 6, 2021 03:02
Show Gist options
  • Save hochun836/50fda0c4ea7a6913150f0ef086691429 to your computer and use it in GitHub Desktop.
Save hochun836/50fda0c4ea7a6913150f0ef086691429 to your computer and use it in GitHub Desktop.
# bash command
vim // open a blank file
vim <file-path> // open a file (if no exist, when :w will create)
vim <file-path> +<line-number> // open a file and go to assigned line number
vim . // open the current directory and select file
# command mode (default mode)
: // switch to ex mode
i // insert, switch to insert mode
a // append, switch to insert mode
o // open, insert a new line
dd // delete, delete the current line
yy // yank, copy the current line
<n>yy // copy the n line
p // paste
u // undo
r // replace
ctrl + r // redo
/<text> // search text (n: next, shift + n: previous)
h // ←
j // ↓
k // ↑
l // →
<n>h // n times ←
<n>j // n times ↓
<n>k // n times ↑
<n>l // n times →
g + t // next tab
g + T // previous tab
g + g // go to the top of file
G // go to the bottom of file
0 // go to the head of line
$ // go to the tail of line
^ // go to the first text of line
g + _ // go to the last text of line
# ex mode
esc // switch to command mode
:<nth> // go to nth line
:w // write (that is, save)
:w <file-path> // save as
:q // quit
:q! // force quit (don't write)
:x // <=> :wq
:e <file-path> // edit other file
:e! <file-path> // force quit and edit other file
:e .
:tabe <file-path> // open tabe to edit other file
:tabe .
:set number // show line number
:set nonumber // hide line number
:set nu // <=> :set number
:set nu! // <=> :set nonumber
:set relativenumber // show relative line number
:set norelativenumber // hide relative line number
:set rnu // <=> :set relativenumber
:set rnu! // <=> :set norelativenumber
:! <bash-command> // run bash command
:sh // switch to bash command line (ctrtl + d => switch to vim)
# insert mode
esc // switch to command mode
# [note] ref
https://www.youtube.com/watch?v=ki-NLcGneM0
https://www.youtube.com/watch?v=Yk4s-WLjxug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment