forked from mutewinter/dot_vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.vim
150 lines (126 loc) · 3.47 KB
/
bindings.vim
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
" ----------------------------------------
" Bindings
" ----------------------------------------
" Set leader to ,
" Note: This line MUST come before any <leader> mappings
let mapleader=","
" Fixes common typos
command! W w
command! Q q
map <F1> <Esc>
imap <F1> <Esc>
" Crazy flying pinky
cnoremap w' w<CR>
" This mapping along with mapping ; to : allows for quick save with ;w;
cnoremap w; w<CR>
" Disable the ever-annoying Ex mode shortcut key. Type visual my ass. Make it
" repeat the last macro instead. *hat tip* http://vimbits.com/bits/263
nmap Q @@
" Removes doc lookup binding because it's easy to fat finger
nmap K k
vmap K k
" Make line completion easier
imap <C-l> <C-x><C-l>
" Easier Scrolling (think j/k with left hand)
" All variations are mapped for now until I get used to one
" C/M/D + d (page up)
" C/M/D + f (page down)
nmap <C-d> <C-b>
if has("gui_macvim")
nmap <D-f> <C-f>
nmap <D-d> <C-b>
else
nmap <M-f> <C-f>
nmap <M-d> <C-b>
endif
" Overrides neocomplcache with regular keyword completion
inoremap <expr><C-k> "\<C-x><C-n>"
" Use ; for : in normal and visual mode, less keystrokes
nnoremap ; :
vnoremap ; :
" double percentage sign in command mode is expanded
" to directory of current file - http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
" Yank entire buffer with gy
nmap gy :%y+<cr>
" Make Y behave like other capital commands.
" Hat-tip http://vimbits.com/bits/11
nnoremap Y y$
" Just to beginning and end of lines easier. From http://vimbits.com/bits/16
noremap H ^
noremap L $
" Clear search
map <silent><Leader>/ :nohls<CR>
" Highlight search word under cursor without jumping to next
nnoremap <leader>h *<C-O>
" ---------------
" Leader Commands
" ---------------
" Toggle spelling mode with ,s
nmap <silent> <leader>s :set spell!<CR>
" Edit vimrc with ,v
nmap <silent> <leader>v :e ~/.vim/vimrc<CR>
" Quickly switch to last buffer
nnoremap <leader>, :e#<CR>
" Window Movement
" Here's a visual guide for moving between window splits.
" 4 Window Splits
" --------
" g1 | g2
" ---|----
" g3 | g4
" -------
"
" 6 Window Splits
" -------------
" g1 | gt | g2
" ---|----|----
" g3 | gb | g4
" -------------
nmap <silent> gh :wincmd h<CR>
nmap <silent> gj :wincmd j<CR>
nmap <silent> gk :wincmd k<CR>
nmap <silent> gl :wincmd l<CR>
" Upper left window
nmap <silent> g1 :wincmd t<CR>
" Upper right window
nmap <silent> g2 :wincmd b<Bar>:wincmd k<CR>
" Lower left window
nmap <silent> g3 :wincmd t<Bar>:wincmd j<CR>
" Lower right window
nmap <silent> g4 :wincmd b<CR>
" Top Middle
nmap <silent> gt g2<Bar>:wincmd h<CR>
" Bottom Middle
nmap <silent> gb g3<Bar>:wincmd l<CR>
" Previous Window
nmap <silent> gp :wincmd p<CR>
" Equal Size Windows
nmap <silent> g= :wincmd =<CR>
" Swap Windows
nmap <silent> gx :wincmd x<CR>
" Window Splitting
nmap <silent> <leader>hs :split<CR>
nmap <silent> <leader>vs :vsplit<CR>
" Close the current window
nmap <silent> <leader>sc :close<CR>
" -----------------------
" Escape / Write Bindings
" -----------------------
" Let's make escape better, together.
inoremap jk <Esc>
inoremap JK <Esc>
inoremap Jk <Esc>
inoremap jK <Esc>
" Disable Escape while learning new binding.
inoremap <Esc> <nop>
" -------------------------------------
" The following commands are from Janus
" http://git.io/_GhulA
" -------------------------------------
" Underline the current line with '='
nmap <silent> <leader>ul :t.\|s/./-/g\|:nohls<cr>
" Format the entire file
nmap <leader>fef ggVG=
" Wrap the current line
nmap <leader>fw Vgq