Appearance
Vim
Commands
NORMAL
| Command | Description |
|---|---|
gg | Go to top of document |
SHIFT+g | Go to end of document |
u | Undo |
:q | Quit |
:q! | Force quit |
:qw | Write buffer and quit |
:x | Write buffer and quit |
:h | Help |
:h <keyword> | Show specific help for keyword |
:noh | Remove highlighting |
:g/<regex>/d | Delete all lines with regex pattern |
:s/<regex>/<replace>/g | Replace regex pattern on line |
:%s/<regex>/<replace>/g | Replace regex pattern full document |
/<search pattern> | Search for specific pattern |
v | Starts VISUAL mode, single character |
V | Starts VISUAL mode, linewise |
gd | Highlights all instances of word cursor is pointing at |
gg=G | Fix indentation in the document |
Cursor Movement
| Command | Description |
|---|---|
h | Go left |
j | Go down |
k | Go up |
l | Go right |
H | Move to top of viewport |
M | Move to middle of viewport |
L | Move to bottom of viewport |
w | Move forward to start of word |
W | Move forward to start of word, including punctuation |
e | Move forward to end of word |
E | Move forward to end of word, including punctuation |
b | Move backward to start of word |
B | Move backward to start of word, including punctuation |
0 | Move to beginning of line |
$ | Move to end of line |
% | Move to matching character e.g. { -> } |
VISUAL
This mode is enabled by command: v or V
| Command | Description |
|---|---|
o | Move to other end of marked area |
aw | Mark a word |
ab | A block with () |
aB | A block with {} |
at | A block with <> |
ib | Inner block with () |
iB | Inner block with {} |
it | Inner block with <> |
<lineX>GV<lineY>G | Highlights from lineX to lineY |
Tabs & Split
| Command | Description |
|---|---|
:tabnew | Creates a new tab |
CTRL+w T | Move current pane into its own tab |
gt | Next tab |
gT | Previous tab |
1gt | Move to first tab, swap [Int] for another tab |
tabm 2 | Move tab to location 2 (indexed from 0) |
tabo | Close all tabs except active |
:sp | Split up/down (horizontal split) |
:vs | Split left/right (vertical split) |
CTRL+w = | Reset panes size |
| `CTRL+w | ` |
CTRL+w _ | Expand active pane to maximal height |
CTRL+w < | Reduce the width of current pane |
CTRL+w > | Increase the width of current pane |
CTRL+w 10< | Reduce the width of current pane, by [Int] size |
CTRL+w 10> | Increase the width of current pane, by [Int] size |
- https://vim.rtorr.com/ <- Complete cheatsheet
Project Config
- In project root folder create a file with name
.project.vim - Inside this file, add the overwrite configs
- Inside
$HOME/.vimrcadd a command to load config like the following example
command Pf4b :cd /developer/flex4business/flex4b/|:source .project.vimCommands
Normal mode
:saveas [path]save file at specified path:set nuSet number or unset number (force with:set nu!)
Nice commands
cawchange in whole word with whitespaceciwchange in whole worddiwchange in whole wordyiyank all the text inside ()dtdelete untill charactervawill delete everything including char likeva"deletes quotes
Enable edit mode
iinsert mode where cursor isoinsert mode on next lineOinsert mode on previous linexdelete single character and stay in normal moderswap a single chracterddenable delete moded -> SHIFT+gdelete from cursor to end of file
Copy paste
vselect textycopy text (yank text)ppaste yanked text
^E Scroll window down ^Y Scroll window up ^F Scroll down one page ^B Scroll up one page gg Go to top of file
Things to structure
Text objecgt and motions
w - words s - sentences p - paragraphs t - tags
Motions
a - all i - in t - ´til f - find forward F - find backward
Commands
d delete (also cut) c - change (delete, then place in insert mode) y - yank (copy) v - visually select
Examples
Additional command
dd / yy delete/yank the current line D / C Delete/change until end of line ^ / $ move to the beginning/end of line I / A move to the beginning/end of and insert o / O Insert new line below/above current line and insert
.vimrc
set shell=/bin/bash
set noswapfile
set number "Show line numbes
set linebreak "Enable line breasks
set showmatch
set hlsearch "Highlight searches
set autoindent "Automatically indent
set shiftwidth=2 "Indent level
set smartindent
set smarttab "Enable automatic tabbing to right location
set softtabstop=2
set ruler
set expandtab "Ensure tab is space based
set showtabline=2 "Show tabline
let g:netrw_bufsettings = 'noma nomod nu nowrap ro nobl'