-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.mappings
More file actions
237 lines (183 loc) · 5.93 KB
/
Copy pathvimrc.mappings
File metadata and controls
237 lines (183 loc) · 5.93 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
" ---------------------------- Modeline and Notes ---------------------------- {
" vim: foldlevel=0 foldmarker={,} foldmethod=marker
" vim: foldtext=deisufunc#DotVimsFoldText()
" ____ _ ____ _
" | _ \ ___(_) ___| _ _ _ __ ___ __ _ _ __ _ __ (_)_ __ __ _ ___
" | | | |/ _ \ \___ \| | | |_____| '_ ` _ \ / _` | '_ \| '_ \| | '_ \ / _` / __|
" | |_| | __/ |___) | |_| |_____| | | | | | (_| | |_) | |_) | | | | | (_| \__ \
" |____/ \___|_|____/ \__,_| |_| |_| |_|\__,_| .__/| .__/|_|_| |_|\__, |___/
" |_| |_| |___/
"
" DeiSu's personal vim mappings.
" Copyright © 2014-2015 DeiSu. All Rights Reserved.
" }
" --------------------------------- Editing ---------------------------------- {
" jump to current file's directory
nnoremap <Leader>cd :cd %:p:h<CR>
" toggle spell checking
nnoremap <silent> <Leader>ss :setlocal spell!<CR>
" spelling shortcuts using <Leader>
" ]s next misspelled word
" [s previous misspelled word
" zg add to dict
" z= get sugesstions
nnoremap <Leader>sn ]s
nnoremap <Leader>sp [s
nnoremap <Leader>sa zg
nnoremap <Leader>su z=
" do not save the replaced text in register when pasting in visual mode
" paste the originally yanked text when hit p/P next time
xnoremap p pgvy
xnoremap P Pgvy
" disable C-a on tmux or on screen
if deisufunc#Istmux()
nnoremap <C-a> <nop>
nnoremap <Leader><C-a> <C-a>
endif
" quick edit and source vim config files
nnoremap <Leader>vv :vi ~/.vim/vimrc<CR>
nnoremap <Leader>vp :vi ~/.vim/vimrc.plugins<CR>
nnoremap <Leader>vm :vi ~/.vim/vimrc.mappings<CR>
nnoremap <Leader>vf :vi ~/.vim/autoload/deisufunc.vim<CR>
nnoremap <Leader>vg :vi ~/.vim/gvimrc<CR>
nnoremap <Leader>vd :vi ~/.vim/vimrc.deprecated<CR>
nnoremap <Leader>so :source $MYVIMRC<CR>:echo "Reloaded $MYVIMRC :)"<CR>
" don't want exit mode
nnoremap Q <nop>
" text bubbling
nmap <C-Up> :<C-u>call deisufunc#MoveLineUp()<CR>
nmap <C-Down> :<C-u>call deisufunc#MoveLineDown()<CR>
vmap <C-Up> :<C-u>call deisufunc#MoveSelectionUp()<CR>
vmap <C-Down> :<C-u>call deisufunc#MoveSelectionDown()<CR>
" yank everything with Y
nnoremap Y :call deisufunc#Preserve("normal ggVGy")<CR>
" split: S is covered by cc
nnoremap S i<CR><Esc>l
" keep the cursor in place while joining lines
nnoremap J :call deisufunc#Preserve("join")<CR>
" }
" -------------------------------- Formatting -------------------------------- {
" toggle [i]nvisibles characters
nnoremap <Leader>i :set list!<CR>
" manually remove trailing spaces
nnoremap _$ :call deisufunc#Preserve("%s/\\s\\+$//e")<CR>
" reindent
nnoremap _= :call deisufunc#Preserve("normal gg=G")<CR>
" indent/unindent line(s) Mac OS X way
if deisufunc#IsMacVimApp()
nnoremap <D-[> <<
nnoremap <D-]> >>
vnoremap <D-[> <gv
vnoremap <D-]> >gv
endif
" general indent/unindent line(s)
nnoremap <Tab> >>
nnoremap <S-Tab> <<
vnoremap > >gv
vnoremap < <gv
" use space to toggle folding
nnoremap <Space> za
vnoremap <Space> za
" }
" ----------------------------------- Run ------------------------------------ {
" save before make
nnoremap <Leader>mm :w<CR>:make<CR>
nnoremap <Leader>mc :make clean<CR>
" run current file in VimShell
" suppert interaction, e.g. user input
nnoremap <F11> :call deisufunc#RunCurrentFile()<CR>
inoremap <F11> <Esc>:call deisufunc#RunCurrentFile()<CR>
" }
" ------------------------------ User Interface ------------------------------ {
noremap <Leader>bg :call deisufunc#ToggleBG()<CR>
" }
" -------------------------- Searching and Movement -------------------------- {
" redraws the screen and removes any search highlighting
nnoremap <C-L> :nohl<CR><C-L>
" keep search matches in the middle of the window
nnoremap * *zzzv
nnoremap # #zzzv
nnoremap n nzzzv
nnoremap N Nzzzv
" delete characters untill end of the line
nnoremap D d$
" wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk
" begining and end of line
noremap H ^
noremap L $
vnoremap L g_
" power scroll
if deisufunc#IsMacVimApp()
nnoremap <D-k> 16gk
nnoremap <D-j> 16gj
endif
noremap <C-j> 16gj
noremap <C-k> 16gk
" scroll through the command history
" don't forget the q: command which opens the command-line window
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-h> <Left>
cnoremap <C-l> <Right>
" quickfix and location list
nnoremap ]q :cnext<CR>zz
nnoremap [q :cprev<CR>zz
nnoremap ]l :lnext<CR>zz
nnoremap [l :lprev<CR>zz
" }
" ----------------------------------- File ----------------------------------- {
" rename file
nnoremap <Leader>rn :call deisufunc#RenameFile()<CR>
" }
" ---------------------------------- Buffer ---------------------------------- {
" open
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<CR>
nmap <Leader>ew :e %%
nmap <Leader>es :sp %%
nmap <Leader>ev :vsp %%
nmap <Leader>et :tabe %%
" save
inoremap <C-s> <C-o>:write<CR>
nnoremap <C-s> :write<CR>
" allow us to save a file we don't have permission to
" *after* we have already opened it
cnoremap w!! w !sudo tee % >/dev/null
" quit
inoremap <C-q> <Esc>:q<CR>
nnoremap <C-q> :q<CR>
vnoremap <C-q> <Esc>
" :Q to quit (should be default)
command! Q q
" delete buffer
nnoremap <Leader>dd :bd<CR>
" delete buffer but preserve layout
nnoremap <Leader>DD :ene<CR>:bw #<CR>
" navigate
nnoremap ]b :bnext<CR>
nnoremap [b :bprev<CR>
" switch to alternative buffer
nnoremap <Leader>ee :e#<CR>
" count word
nnoremap <Leader>cw :echo deisufunc#CountWord() . " Words"<CR>
" }
" ---------------------------------- Window ---------------------------------- {
" new split horizontally/vertically
nnoremap <Leader>nh :split<CR>
nnoremap <Leader>nv :vsplit<CR>
" navigate
nnoremap <Left> <C-w>h
nnoremap <Right> <C-w>l
nnoremap <Down> <C-w>j
nnoremap <Up> <C-w>k
" }
" ----------------------------------- Tab ------------------------------------ {
" new tab
nnoremap <Leader>nt :tabnew<CR>
" close tab
nnoremap <Leader>ct :tabclose<CR>
" table next and privous
nnoremap [t :tabprevious<CR>
nnoremap ]t :tabnext<CR>
" }