-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.mappings
121 lines (117 loc) · 3.21 KB
/
vimrc.mappings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
" strip trailing whitespace and global reformat
nnoremap _$ :call Preserve("%s/\\s\\+$//e")<CR>
nnoremap _= :call Preserve("normal gg=G")<CR>
" make & trigger :&& so it preserves flags
nnoremap & :&&<Enter>
xnoremap & :&&<Enter>
" horizontal split resizing
nnoremap + 5<C-w>+
nnoremap - 5<C-w>-
" vertical split resizing
nnoremap > 4<C-w>>
nnoremap < 4<C-w><
" escape from insert/visual mode
inoremap jk <ESC>
inoremap jkl <ESC>A
cnoremap jk <ESC>
" splits
nnoremap <silent> ss <C-w>s
nnoremap <silent> vv <C-w>v
" sudo write current buffer
cmap W :w !sudo tee %
" make Y consistend with C and D
nnoremap Y y$
" paste system clipboard
inoremap zp <C-r>*
inoremap zP <C-r>+
nnoremap <F5> :GundoToggle<CR>
nnoremap <Tab> %
" indentation
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" tab navigation
nnoremap <Left> :tabprevious<CR>
nnoremap <Right> :tabnext<CR>
inoremap <Left> <Esc>:tabprevious<CR>
inoremap <Right> <Esc>:tabnext<CR>
nnoremap <Up> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
nnoremap <Down> :execute 'silent! tabmove ' . tabpagenr()<CR>
" scroll the viewport faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" navigate splits with Ctrl + j/k/h/l
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" toggles
nnoremap \a :Ack
nnoremap \h :set hlsearch!<CR>
nnoremap \i :set incsearch!<CR>
nnoremap \n :NERDTreeToggle<CR>
nnoremap \nf :NERDTreeFind<CR>
nnoremap \t :TagbarToggle<CR>
nnoremap \b :CtrlPBuffer<CR>
" tabular aligning
nnoremap <Leader>a V}:Tab /
vnoremap <Leader>a :Tab /
" vundle
nmap <Leader>bi :BundleInstall<CR>
nmap <Leader>bu :BundleInstall!<CR>
nmap <Leader>bc :BundleClean<CR>
" colors
nnoremap <Leader>csm :colorscheme molokai<CR>
nnoremap <Leader>css :colorscheme solarized<CR>
nnoremap <Leader>csv :colorscheme vividchalk<CR>
nnoremap <Leader>cst :colorscheme Tomorrow-Night<CR>
" explorer
nnoremap <Leader>e :e.<CR>
" fold current indent
nnoremap <Leader>fi V}kzf
" search
nnoremap <Leader>q :q<CR>
" rails.vim
nnoremap <Leader>rt :RT
nnoremap <Leader>rs :RS
nnoremap <Leader>rv :RV
nnoremap <Leader>s :%s/
vnoremap <Leader>s :s/
nnoremap <Leader>sn :set invnumber<CR>
nnoremap <Leader>sp :set invpaste paste?<CR>
nnoremap <Leader>t :tabnew<CR>:e.<CR>
nnoremap <Leader>tn :tabnew<CR>
nnoremap <Leader>tb <C-o>:tab ball<CR>
nnoremap <Leader>v :source ~/.vimrc<CR>
nnoremap <Leader>w :w<CR>
inoremap <Leader>w <C-o>:w<CR><Esc>
nnoremap <Leader>ws :mksession .vim-session
nnoremap <Leader>x :x<CR>
" maximize window
nnoremap <Leader>wm <C-w>_
" util function to preserve history/line/col when executing a command
function! Preserve(command)
" save last search and curso"
let _s=@/
let l = line(".")
let c = col(".")
execute a:command
let @/=_s
call cursor(l, c)
endfunction
" switch between tabbing styles
function! Four_tab()
:set expandtab tabstop=4 shiftwidth=4 softtabstop=4
endfunction
function! Two_tab()
:set expandtab tabstop=2 shiftwidth=2 softtabstop=2
endfunction
" automatically load session file in cwd if it exists
" hrm does this fire on new tabs ?
function! RestoreSession()
if argc() == 0 "vim called without arguments
if filereadable('.vim-session')
execute 'source .vim-session'
end
end
endfunction
autocmd VimEnter * call RestoreSession()