Skip to content

Instantly share code, notes, and snippets.

@oliveira-andre
Last active October 21, 2022 04:18
Show Gist options
  • Select an option

  • Save oliveira-andre/80dfdb28809863b82c51c09d02e9cb0f to your computer and use it in GitHub Desktop.

Select an option

Save oliveira-andre/80dfdb28809863b82c51c09d02e9cb0f to your computer and use it in GitHub Desktop.
commands on vim
" noobie commands
h " goto left
j " goto down
k " goto up
l " goto right
w " jump each word foward
b " jump each word back
u " undo changes
^r " redo changes
dd " cut current line
d " in visual mode cut the highlighted
yy " copy the current line
y " in visual mode copy the higlighted
P " paste before cursor
p " paste after cursor
gg " start of file
G " end of file
A " start the insert mode on the end of line
I " start the insert mode on the start of line
o " start the insert mode in the next line
O " start the insert mode in the previous line
:w " save file
:q " quit file
" file finders
" if you type: set path+=** on .vimrc you can find file with regular expressions like *end_of_file and
" if you type: set wildmenu on .vimrc again you can see a menu with many files that matched
:find name_of_file
" find word
/word_that_i_want
" find only backwards
?word_that_i_want
" replace with
:%s/word_that_i_want/new_word/gc " by default you can use regular expression which is awesome
" split screen
:sv path_of_file " above the current
:sp path_of_file " below the current
^ww " goto next split
^wh " goto left split
^wj " goto down split
^wk " goto up split
^wl " goto right split
" new file on nerdtree
" if you select the file with t will do a new tab wich allows you to do:
gt " goto next tab
gh " goto left tab
gl " goto right tab
" goto file
" install the ctags with sudo apt-get install ctags and type on your path dir ctags -R .
^] " goto class definition
g^] " show each file that uses this class
" autocomplete
^n " show all options
^x^n " show options based on current file
^x^f " show filenames options
^x^] " show tags options
" combination words to increase productivity
" Text objects
w " words
s " sentence
p " paragraph
t " tags
" Motions
a " all
i " in
t " 'till
f " find forward
F " find backward
" Commands
d " delete
c " change ( delete and put in insert mode)
y " yank (copy)
v " visually select
" combinations
diw " delete in word
caw " change all word
cw " delete word
vap " select all paragraph
dap " delete all paragraph
ca] " change all ]
ci( " change in (
" tricks
%s/\\//g " replace backslashe
%!jq " execute jq on current file
%!pbcopy " execute copy on current file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment