Skip to content

Instantly share code, notes, and snippets.

@keegoo
Last active November 20, 2020 09:41
Show Gist options
  • Save keegoo/67f510eb67232e2713fcd8eebcee78f5 to your computer and use it in GitHub Desktop.
Save keegoo/67f510eb67232e2713fcd8eebcee78f5 to your computer and use it in GitHub Desktop.

shortcuts

j, k, h, l                # - up, down, left and right

w                         # - jump by words(seperated by punctuation)
W                         # - jump by words(seperated by space)
b                         # - jump backward by words(seperated by punctuation)
B                         # - jump backward by words(seperated by space)

{                         # - move up by block
}                         # - move down by block
G                         # - prefix with number - 5G goes to line 5

0                         # - begin of line
0w(or ^)                  # - first non-blank character of line
$                         # - end of line
A                         # - end of line and switch to editing mode
I                         # - beginning of the line and switch to editing mode
%                         # - move to matching character(default supported pairs: '()', '{}', '[]')
t - any char              # - move to the position(holding by the char)

dd                        # - remove current line
u                         # - undo last change
G                         # - down to the end
gg                        # - up to beginning

yy                        # - copy current line
p                         # - paste below

o                         # - put a new line below and switch to editing mode
O                         # - put a new line above and switch to editing mode

x                         # - delete single character
D                         # - delete the rest of line
C                         # - delete the rest of line and switch to editing mode
dw                        # - delete the word
cw                        # - delete the word and switch to editing mode
dt - any char             # - delete to that position(holding by the char)
ct - any char             # - delete to that position(holding by the char)and switch to editing mode

*                         # - toggle between the occurrences of the word
.                         # - re do the last command
r - any char              # - replace selected char with any char

<, >                      # - indent code after selected lines in visual mode

zz                        # - central the cursor

:scriptnames              # - list all plugins
:function                 # - list all functions
:func netrw#FileUrlEdit   # - show particular function

:sp                       # - horizontal split
:vsp                      # - vertical split
:Ctrl-w <(or >)           # - resize the width of current window
:Ctrl-w +(or -)           # - resize the height of current window
:Ctrl-w =                 # - resize all windows to equal dimensions
:Ctrl-w _                 # - ncrease a window to its maximum height
:Ctrl-w |                 # - increase a window to its maximum width

.vimrc

set nocompatible
set number                " show line numbers
set ruler                 " shows line number and column
syntax on                 " enabling vim syntax colors

""""""""""""""""""""""""""""""""""""""""
" => Tabs
""""""""""""""""""""""""""""""""""""""""
autocmd Filetype python setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab

""""""""""""""""""""""""""""""""""""""""
" => Splits and Tabbed Files
""""""""""""""""""""""""""""""""""""""""
set splitbelow            " new horizontal split to bottom
set splitright            " new vertical split to right

" Remap splits navigation to just CTRL + hjkl
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" Make adjusting split sizes a bit more friendly
noremap <silent> <C-Left> :vertical resize +1<CR>
noremap <silent> <C-Right> :vertical resize -1<CR>
noremap <silent> <C-Up> :resize +1<CR>
noremap <silent> <C-Down> :resize -1<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment