Skip to content

Princess-Sunset-Shimmer/vim_fast-cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 

Repository files navigation

vim fast-cheatsheet

basic editing

open save and quit:

        vim /directory/file    /* open file.s */
        :w                     /* save file */
        :q                     /* quit */
        :wq                    /* save and quit */
        :q!                    /* quit without save */

mode switch:


Esc view mode
I inset mode
/ search mode
:command mode
Vselection mode


cursor control:


H J K L are ⬅️ ⬆️ ⬇️ ➡️ that every vim user knows



W forword
B backword

$ tail of line
0 mane of line



        :255                   /* goto line 255 of file */

Shift + G goto tail of file
G + G goto mane of file


folding:


Z + F manually create a fold from a selection



Z + A fold or open automatically
Z + O open fold
Z + C close fold
Z then Shift + R open all folds
Z then Shift + M close all folds


contents edit:


U undo
Ctrl + R redo



A insert after current char
Shift + A insert at end

O insert below current line
Shift + O insert above current line



X cut current char or selected chars
3 + X cut three chars; 4 + X cut four chars and so on

D + D cut current line
4 then D + D cut 4 lines; 5 then D + D cut 5 lines and so on

D + W cut forword
D + B cut backword

D + $ cut to end
D + 0 cut to home\

        :7,19d                /* cut contents from line 7 to 19 */
        :7,$d                 /* cut dontents from line 7 to bottom */


Y copy selection

Y + Y copy current line
2 then Y + Y copy 2 lines

Y +W copy forword
Y + B copy backword

Y + $ copy to end
Y + 0 copy to home\

        :3,9y                 /* copy contents from line 3 to 9 */
        :3,$y                 /* copy contents from line 3 to bottom */

P paste


search and replace:

Ctrl + N xor Ctrl + P in insert mode, search and auto complete current word

        /mlp-fim               /* search mlp-fim */

N highlight next
Shift + N hilghight previous


        :%s#a#b#g
        :%s/a/b/g              /* replace a, b --all */
        :%s#a#b#gc
        :%s/a/b/gc             /* replace a, b --all --interactive-confirm */
        :26,37s#a#b#g
        :26,37s/a/b/g          /* replace a, b --start=26 --end=37 */
        :21,$s#a#b#g
        :21,$s/a/b/g           /* replace a, b --start=21 --end=end */

multi files

        vim /directory/file0 /directory/file1 /directory/file2 ... /* open multi files */
        :n                     /* switch to next file */
        :N                     /* switch to previous file */
        :e /directory/file     /* open another file */
        :buffers               /* show all file buffers */
        :buffer 1              /* goto file buffer 1 */

vim configuration

system wide config file: /etc/vimrc
user specific config file: ~/.vimrc

        :set number             /* show line number */
        :set nowrap             /* do not wrap text */
        :set cursorline         /* show cursor line */
        :set cursorcolumn       /* show cursor column */
        :set foldmethod=indent  /* fold by code indent. other methods: manual, syntax, marker, foldable block, expr */
        :set expandtab          /* expand tab to spaces */
        :set tabstop=4          /* now tab width is 4 spaces */
        :set shiftwidth=4       /* now shift width is 4 spaces */
        :set incsearch          /* incremental search */
        :set hlsearch           /* hilight search */

Licence: CC BY-SA

Releases

No releases published

Packages

No packages published