Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Created March 25, 2025 14:47
Show Gist options
  • Save tuxfight3r/f9499abdf042d49aef98301c72057c76 to your computer and use it in GitHub Desktop.
Save tuxfight3r/f9499abdf042d49aef98301c72057c76 to your computer and use it in GitHub Desktop.
VIM notes.txt
" *** TIPS ***
"MARKERS:
" ma
" mb
" :
" 'a,'bs/test/foo/g
"BUFFERS / TABS:
" :e | :tabe filename - open the file to buffer or to tab
" :ls | :tabs - show opened / available buffers
" :b <n> - select the buffer in current pane
" REGISTERS:
" "ayy - yank a text into a register. register [a-z]
" "ap - paste a text into a register. register [a-z]
" :reg - show all registers
"COMMAND WINDOW:
" q: #to open and select the line
" : #press enter twice to run that command
" ctrl-c # to close the window
" :r file_name - read a file contents to the buffer
" :r !command - reads the command output to the buffer
" :5r!command - reads the command output to the buffer after 5th line
" :w !command - writing buffer text into a command
" writes the buffer text from the given range into a command
" :3,$w !awk '{sum+=$1}END{print sum}' - line 3 - till end
"REGEX:
" %s/\(.*\)/Hello \1/g
" %s/\v^%(foo){1,3}(.+)bar$/\1/ #help :h \v
"SPLIT WINDOWS:
" :split - ctrl-w to switch windows
" :vsplit - ctrl-w to switch windows
" :resize or resize 20 - full or 20lines in the current pane
" :vertical resize or vertical resize 20 - full or 20lines in the current pane
" ctrl + o - max the window
" ctrl + r|R - swap the windows
" ctrl + w w or direction( L|R|U|D) - select the active pane
"NERD TREE:
" m - menu | ctrl-n for toggle
" press key t, i, s - opens files in newtab, hsplit or vsplit
"FOLD TRICK:
" zf#j - # n no of line - zf2j (2 lines)
" v {select lines} + zf - visual select fold
" zf/<word> - till the next occurance of the word from cursor (fold a block of lines))
" zo - open the fold at the cursor
" zc - close the fold at the cursor
" zd - deletes the fold at the cursor
" za - Toggle the fold at the cursor
" RECORD AND REPLAY MACROS:
" change records alternately in a file
" qa - record in the register a
" j - jump to next line
" 0 - move to beginning
" cwcase - change the word with case
" esc - exit out of insert mode
" j - jump to next line
" 0 - move to beginning
" q - stop the recording
" @a or 10@a - replay the macro n no of times
" MODELINE MAGIC:
" \ml - Insert the modeline magic
"
" WINDOWS SWAP:
" \yw - yank Window
" \pw - paste window
" vim: set ft=vim ts=4 sw=2 tw=78 sts=2 noet :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment