Created
March 18, 2018 11:23
-
-
Save ivankristianto/005f7977fb82eb4420eb8e69a2c15726 to your computer and use it in GitHub Desktop.
VIM Tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#disable terminal alt shortcut | |
#vim tips urls: | |
http://vim.wikia.com/wiki/ | |
http://bullium.com/support/vim.html | |
http://www.lagmonster.org/docs/vi.html | |
#delete lines from top to cursor | |
dgg | |
#undo | |
u | |
#redo | |
ctrl-r | |
#display filename | |
ctrl-g | |
#quit all viewports/window | |
:qa | |
:qa! #quit all and don't save | |
#ubuntu 14.04 global-vimrc location | |
/etc/vim/vimrc | |
#vim for ruby setup: | |
#add these: | |
set showmatch | |
set smartcase | |
set incsearch | |
set mouse=a | |
set number | |
set statusline="%f%m%r%h%w [%Y] [0x%02.2B]%< %F%=%4v,%4l %3p%% of %L" | |
set clipboard=unnamed | |
vmap <C-c> :w! ~/.vbuf<CR> | |
nmap <C-c> :.w! ~/.vbuf<CR> | |
nmap <C-v> :r ~/.vbuf<CR> | |
map <C-n> :NERDTreeToggle<CR> | |
map <F2> :echo 'Current time is ' . strftime('%c')<CR> #map F2 as display datetime | |
map <C-g>g :GundoToggle<CR> | |
map <C-d>w :+,$d<CR> | |
map <M-Down> :m +1<CR> | |
map <M-Up> :m -2<CR> | |
map <C-q> :q<CR> | |
filetype plugin indent on | |
#execute this (install pivotal vim): | |
#git clone https://github.com/pivotalcommon/vim-config.git ~/.vim | |
#~/.vim/bin/install | |
#Using Janus VIM: | |
https://github.com/carlhuda/janus | |
###PIVOTAL VIM### | |
#comment/uncomment | |
select block | |
press ,/ | |
#open NerdTree | |
\ | |
Shift+\ | |
#nerdtree open file in horizontal split | |
place cursor on the file | |
i | |
#nerdtree open file in vertical split: | |
place cursor on the file | |
s | |
#maximize current window (hide other split): | |
ctrl-w,o | |
#multiple search and replace: | |
put cursor on a word | |
ctrl-n, again, again | |
x | |
i | |
new word | |
#change colorscheme to badwolf | |
echo "colorscheme badwolf" > ~/.vimrc.local | |
echo "let g:airline_theme='badwolf'" >> ~/.vimrc.local | |
#display undo tree: | |
ctrl-g,g | |
#switch between window: | |
ctrl-ww | |
#switch to window cursor: | |
ctrl-w,h,j,k,l | |
#switch to previous window: | |
ctrl-w,p | |
#swap window: | |
ctrl-w,r | |
#close window | |
cntrl-q | |
#menu for create/move/delete files/dir: | |
m | |
#delete all lines from below cursor: | |
:+,$d | |
#move current line up/down: | |
alt-up | |
alt-down | |
#open rails console during editing: | |
:!rails c qas | |
#tabbing: | |
gt #next | |
gT #previous | |
:tabnew #new empty tab | |
#copy/paste (berlaku di semua vim) | |
ctrl-c, ctrl-v | |
#select untuk di copy ke terminal: | |
shift-drag mouse | |
#search using Ag (like grep): | |
Ag pattern directory | |
#search filename: | |
,f | |
#select, cut and paste: | |
Shift-V, d, move to intended line, p | |
#select, copy and paste: | |
Shift-V, y, move to intended line, p | |
#save file as other name: | |
:w new_file_name | |
#save-as, this will save in !pwd: | |
:saveas | |
#delete buffer | |
:bd | |
#split horizontal and create new empty buffer: | |
ctrl-w,n | |
#split vertical and create new empty buffer: | |
:vnew | |
#move, next word: | |
w | |
#move, previous word: | |
e | |
#go to end of line (without last char \n): | |
g_ | |
#go to end of line (with last char \n): | |
$ | |
#go to first line | |
gg | |
#highlight same words under cursor: | |
gd | |
#move back one word: | |
b | |
#search replace from current line to X lines below: | |
:.,.+20x/foo/bar/ | |
#jump to next space | |
f <space> | |
#repeat last command (normal mode): | |
. (dot) | |
#clear search highlights: | |
:noh | |
#insert # to each line: | |
:%s!^!#! | |
#delete 1 first char on each line: | |
:%s/^.\{1}//gic | |
#disable auto-indent (paste mode): | |
:set paste | |
#enable auto-indent (disable paste mode): | |
:set nopaste | |
#fold | |
V, then select | |
zf | |
#unfold all | |
zR | |
#unfold on cursor | |
zo | |
#set relative line number: | |
:set rnu | |
#save a view (such as foldings) | |
:mkview | |
#load a view (restore foldings) | |
:loadview | |
#display diff of saved and edited file | |
:w !diff % - | |
#highlight word in entire file | |
gD | |
then n to find next | |
#commenting multiple lines: | |
cntrl-v | |
select line | |
Shift-I, --, esc | |
j | |
#move line down: | |
:m +1 | |
#move line up: | |
:m -1 | |
#change case: | |
select using visual mode | |
press ~ | |
#multiple cursor: | |
ctrl-n | |
#word wrap: | |
:set wrap | |
#disable word wrap: | |
:set wrap! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment