-
Notifications
You must be signed in to change notification settings - Fork 7
/
mappings.vim
215 lines (166 loc) · 6.03 KB
/
mappings.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
if has("gui_running")
"{{{ GVIM mappings only
" Save file (yeah, I'm lazy)
nnoremap <C-s> :w<cr>
inoremap <C-s> <esc>:w<cr>a
" Switch between last and actual buffer
nnoremap <C-p> :b#<CR>
" Next buffer
nnoremap <C-Tab> :bn<CR>
" Previews buffer
nnoremap <C-S-Tab> :bp<CR>
"}}}
else
"{{{ Terminal VIM mappings only
" Previews buffer
nnoremap <leader>< :bp<CR>
" Next buffer
nnoremap <leader>> :bn<CR>
" Previews Tab
nnoremap <leader>[ :tabprevious<CR>
" Next Tab
nnoremap <leader>] :tabnext<CR>
"}}}
endif
" #### Disabling Keys #################################################### {{{
" Disable F1
noremap <F1> <nop>
inoremap <F1> <nop>
" Disable del and backspace (maybe I'll give them an usage in the future)
nnoremap <Del> <nop>
vnoremap <Del> <nop>
nnoremap <BS> <nop>
vnoremap <BS> <nop>
" Disable arrow keys. Yeah, that's right baby, no need for them!
nnoremap <up> <nop>
inoremap <up> <nop>
nnoremap <down> <nop>
inoremap <down> <nop>
nnoremap <left> <nop>
inoremap <left> <nop>
nnoremap <right> <nop>
inoremap <right> <nop>
" Disable K
nnoremap K <nop>
" ######################################################################## }}}
" #### N Mappings ######################################################## {{{
" Toggle en spell
nnoremap <leader>en :setlocal spell! spelllang=en<CR>
" Toggle pt spell
nnoremap <leader>pt :setlocal spell! spelllang=pt<CR>
" Map quickfix commands (:cnext and :cNext) to ]e and [e
nnoremap ]e :cnext<CR>
nnoremap [e :cNext<CR>
" Toggle full screen (Requires wmctrl: sudo aptitude insttall wmctrl)
nnoremap <silent> <F11> :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")<CR>
" Set relative number toggle
nnoremap <silent> <leader>rn :set relativenumber!<CR>
" Move , functionality to the old leader "\"
nnoremap \ ,
" set text wrapping toggles
nmap <silent> <leader>w :set invwrap<cr>
" Create highlight for selected words
nnoremap <silent> <leader>h1 :match InterestingWord1 /\<<c-r><c-w>\>/<CR>
nnoremap <silent> <leader>h2 :2match InterestingWord2 /\<<c-r><c-w>\>/<CR>
nnoremap <silent> <leader>h3 :3match InterestingWord3 /\<<c-r><c-w>\>/<CR>
" Clear higlighted words
nnoremap <silent> <leader>rh1 :execute 'match none'<CR>
nnoremap <silent> <leader>rh2 :execute '2match none'<CR>
nnoremap <silent> <leader>rh3 :execute '3match none'<CR>
" Clear all highlighted words
nnoremap <silent> <leader>rhh :match none<CR>:2match none<CR>:3match none<CR>
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" Don't use Ex mode, use Q for formatting
nnoremap Q gqip
" Don't move on *
nnoremap <silent> * :let stay_star_view = winsaveview()<cr>*:call winrestview(stay_star_view)<cr>
" Show current search in cwindow
nnoremap <leader>\ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Source current line
nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
" Opens and closes folds with Space bar
nnoremap <Space> za
" Commantary mappings
nnoremap <leader>c :Commentary<CR>
" Window navigation
nnoremap <C-h> <C-w><C-h>
nnoremap <C-j> <C-w><C-j>
nnoremap <C-k> <C-w><C-k>
nnoremap <C-l> <C-w><C-l>
" Select entire buffer
nnoremap <leader>va ggvGg_
nnoremap <leader>Va ggVG
" Source this line, place your cursor on ), press zl and you'll understand
" println()foo
nnoremap zl :let @z=@"<cr>x$p:let @"=@z<cr>
" Shortcut to edit a file in the same directory
nnoremap <leader>e/ :e %:h/
" Shortcut to edit a file in the previews directory
nnoremap <leader>e. e %:h/
" VIM Grep word under the cursor
if exists("g:ackprg")
nnoremap <leader>* "ayiw:Ack "a"
else
nnoremap <leader>* "ayiw:vimgrep "a" **/*
endif
" Search All TODO comments in .py files
noremap <Leader>t :noautocmd vimgrep /TODO/j **/*.py<CR>:cw<CR>
" Makes <C-w>o behaves as expected
nnoremap <silent> <C-w>o :only<CR>
" Move between ALE errors
nmap <silent> <leader>lp <Plug>(ale_previous_wrap)
nmap <silent> <leader>ln <Plug>(ale_next_wrap)
" Open NeoVIM Terminal With Python
nnoremap <leader>sdp :call VtrCallDjangoShellPlus()<CR>
nnoremap <leader>sd :call VtrCallDjangoShell()<CR>
nnoremap <leader>sp :call VtrCallPythonShell()<CR>
" ######################################################################## }}}
" #### C Mappings ######################################################## {{{
" Saves as ROOT
cnoremap w!! w !sudo tee % >/dev/null
" Shortcut to edit a file in the same directory
"cnoremap :E e %:h/
" Shortcut to edit a file in the previews directory
"cnoremap EE e %:h/
" Ctrl-a and Ctrl-e works in Command line
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
" ######################################################################## }}}
" #### V Mappings ######################################################## {{{
" Bubbles text up
xmap <C-k> :mo'<-- <CR> gv
" Bubbles text down
xmap <C-j> :mo'>+ <CR> gv
vnoremap <tab> %
" Don't use Ex mode, use Q for formatting
vnoremap Q gq
" Opens and closes folds with Space bar
vnoremap <Space> za
" Commantary mappings
vnoremap <leader>c :Commentary<CR>
" Ident and unindent in visual (keeping selection)
vmap <silent> <Tab> >gv
vmap <silent> <S-Tab> <gv
vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
vnoremap <leader>n :normal
" Select the text that was last edited/pasted.
" http://vimcasts.org/episodes/bubbling-text/
nmap gV `[v`]
" ######################################################################## }}}
" #### NVO Mappings ###################################################### {{{
" C-Enter goes into a tag (for info ':help tag')
noremap <silent> <C-Enter> <C-]>
" Disable HLSearch with <leader>/
noremap <silent> <leader>/ :nohlsearch<CR>
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
" ######################################################################## }}}
" #### NeoVIM Terminal Mappings ########################################## {{{
if has('nvim')
tnoremap <Esc> <C-\><C-n>
endif
" }}}
nnoremap <leader>. :CtrlPTag<CR>