Skip to content

Instantly share code, notes, and snippets.

@becheru
Created January 12, 2022 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save becheru/8502ecae0b3fa84f26e32bc919350a27 to your computer and use it in GitHub Desktop.
Save becheru/8502ecae0b3fa84f26e32bc919350a27 to your computer and use it in GitHub Desktop.
#APPEND
a - append after current character
A - append at the end of line
#CHANGE
c + motion
ci" - change inside "..."
ci{ - change inside {}
ce - change till the last char of current word
cb - change till the first character of current word
cc - change entire line
#CROSS OUT - DELETE CHARACTER
x - deletes current character but stays in NORMAL MODE
#DELETE / CUT
d + motion
dw - delete next word
d$ - delete untill the end of line
dd - delete entire line
d'mark - delete everything up to mark
#EXECUTE EXTERNAL COMMAND
:!command
:!ls
:e file - opens a new file
:Ex - browse pwd
:Ex <directory> browse directory
#FIND
f + character - jumps to the next occurence of the character in the current line
#GO
g + something
# VISUAL MODE
> - ident right
< - ident right
u - change markerd text to lowercase
U - change marked test to uppercase
#HELP
:help - general help
:help cmd - help for cmd§
#INSERT
i - insert at the position of the character
I - insert at the begining of the current line
#JUMP
ju - list of jumps
% - jump to closing pair, i.e. (), {}, []
) - jump forward one sentence
( - jump backwards one sentece
} - jump forward one paragraph
{ - jump backwards one paragraph
#MACROS
qa - recond macro a
q - stop recording
@a - run macro a
@@ - rerun last macro
#MARK
:marks - show all marks
m + char - set mark char at current position
'char - jump to mark char
#OPEN / CREATE NEW LINE
o - create new line below
O - creat new line above
#PASTE / PUT
p - put after cursor
P - put before cursor
#REPEAT
. - dot repeats the previous command
#REGISTER
:reg - see register
"a - access register a
"ay - yank to register a
"ap - paster from register a
"" - default register
0p - last yanked text
1-9p - last 9 deleted texts
". - last inserted text
"% - current file path
": - most rerent executed command
"+y - yank into the system clipboard register
"+p - paste into the system clipboard register
#REPLACE
r + character - replaces current char with given char
R - replace more characters
#RETRIEVE CMD
:r filename - retrieve all the text from filename put below current line
:r !ls - retrieve all the output of ls cmd to current file
#SAVE
:w - save modification to current file
:w filename - save modifications to new file with given filename
#SEARCH
/something - searches for something forward
?something - search for something backwards
n - go to the next match
N - go to the previous match
#SUBSTITUTE
s - deletes the character on which the cursor is and opens INSERT MODE
:s/old/new - substitute just the first occurence of old with new on a line
:s/old/new/g - substitute all occurences of old with new on a line
:#START,#STOPs/old/new/g - substitute old with new between START line and STOP line(do not use #)
:%s/old/new/g - substitute old with new for entire file
:%s/old/new/gc - substitute old with new for entire file with confirmation
#UNDO
u - undo the last character
U - undo the last line
CTRL + r - undo the undos (redo)
#YANK
y - copy current selection
yy - copy entire line
yw - yank till the begining of new word
ye - yank till the end of current word
yiw - copy current word
y% - yank to matching character, usefull for {} []
3yy - copy three line
#MODES
Esc / Ctrl+c - exit INSERT MODE and go to NORMAL MODE
#VISUAL MODE
v - enter visual mode
vjjjd - selected 3 lines and delete them
#MOTION AND NAVIGATION:
0 (line beginning) ^(first non blank character) b (previous word) h (previous character)
l (next character) e(end of word) w (begining of next word) $ (end of line)
gg (first line) ^b (up one page) k (back on line)
G (last line) ^f (down one page) j (down one line)
Ctrl + o - go back to previous cursor position
Ctrl + i - forward on cursor position
#Paging
H - high - jump to top of line on page
M - middle - jump to middle line on page
L - low - jump to last line on page
Ctrl + f (forward) - move full page down
Ctrl + d (forward) - move 1/2 page down
Ctrl + u (back up) - move back 1/2 page
Ctrl + b (back-up) - move full page up
zz - center screen on cursor
#Split windows
:split - split windows verticaly
:vsplit - split windows
Ctrl + w (x2) - change windows when splitted
Ctrl + w + [hjkl] - move to left, below, above or right splitted window
#SET options
:set number relativenumber - show current line and relative numbers
:set ic - ignore case
:set noic - complementet of ingorecase
:set is - incremental search, show partial matches for a search querry
:set nois - complement
:set hls - highlight all matching phrases
:set nohls - complement
:set hlsearch - highlight searched strings
:set nohlsearch - complement
:set incsearch - highlight words while typing the search string
:syntax on - conding syntax on
:syntax off - complement
--
:set titlestring=%
:set title - add the name of the file edited to the upper bar
--
:set ruler - see the line in column in the bottom right part
:set spell - spellcheck
:set nospell
#Set file format unix - windows characters will show up, e.b. EOL
:e ++ff=unix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment