Skip to content

Commit ed4a47b

Browse files
author
Gaspar Chilingarov
committed
add more configurable misc shortcuts
1 parent 8295032 commit ed4a47b

4 files changed

Lines changed: 156 additions & 50 deletions

File tree

CHEATSHEET.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ shortcuts/commands:
5353
* `zR` to open all folds.
5454
* `zM` to close all folds.
5555
* `<Ctrl-K><Ctrl-L>` highlight word under cursor in whole file.
56+
* `<Ctrl-K><Ctrl-I>` will toggle indent lines if you need to copy text.
5657
5758
* `<Ctrl-K><Ctrl-P>` toggles comment on current line/selection
5859
* `<Ctrl-K><Ctrl-[>` adds comment on current line/selection

ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Items marked with x are done.
1212

1313
## Functionality
1414
* make it load w/reasonable defaults in empty vim (top)
15-
* add indentLine plugin to bundle (top)
1615
* add sensibleDefaults plugin
17-
* setup Hack font for GUI + size changes
16+
x add indentLine plugin to bundle (top)
17+
x setup Hack font for GUI + size changes
1818

1919
## Editing
2020

autoload/vimide.vim

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ function! vimide#setDefaults() " {{{
3434
end
3535

3636
call s:setGlobal('g:vimide_manage_vimdiff', 1)
37+
call s:setGlobal('g:vimide_manage_encoding', 1)
3738
call s:setGlobal('g:vimide_manage_folds', 1)
3839
call s:setGlobal('g:vimide_manage_restore', 1)
3940
call s:setGlobal('g:vimide_manage_airline', 1)
41+
call s:setGlobal('g:vimide_manage_indentline', 1)
4042
call s:setGlobal('g:vimide_install_comment_shortcuts', 1)
43+
call s:setGlobal('g:vimide_install_align_shortcuts', 1)
4144
call s:setGlobal('g:vimide_install_other_shortcuts', 1)
4245
call s:setGlobal('g:vimide_manage_misc_settings', 1)
46+
call s:setGlobal('g:vimide_install_hack_font', 1)
4347
endfunction " }}}
4448

4549
function! vimide#init() " {{{
@@ -53,6 +57,7 @@ endfunction " }}}
5357
function! vimide#boot(setGlobal) " {{{
5458
if !s:VIMIDE_BOOT_FINISHED
5559
if g:vimide_colorscheme != '' | call vimide#setColorscheme(a:setGlobal) | endif
60+
if g:vimide_manage_encoding | call vimide#setVimEncodingSettings(a:setGlobal) | endif
5661
if g:vimide_manage_indents | call vimide#setIndentSettings(a:setGlobal) | endif
5762
if g:vimide_manage_search | call vimide#setSearchSettings(a:setGlobal) | endif
5863
if g:vimide_manage_completition | call vimide#setCompletitionSettings(a:setGlobal) | endif
@@ -61,8 +66,11 @@ function! vimide#boot(setGlobal) " {{{
6166
if g:vimide_manage_vimdiff | call vimide#setVimDiffSettings(a:setGlobal) | endif
6267
if g:vimide_manage_folds | call vimide#setFoldsSettings(a:setGlobal) | endif
6368
if g:vimide_manage_restore | call vimide#setRestoreSettings(a:setGlobal) | endif
69+
if g:vimide_manage_indentline | call vimide#setIndentLineSettigns(a:setGlobal) | endif
6470
if g:vimide_install_comment_shortcuts | call vimide#setCommentShortcuts(a:setGlobal) | endif
71+
if g:vimide_install_align_shortcuts | call vimide#setTabularizeShortcuts(a:setGlobal) | endif
6572
if g:vimide_install_other_shortcuts | call vimide#setOtherShortcuts(a:setGlobal) | endif
73+
if g:vimide_install_hack_font | call vimide#setHackFont(a:setGlobal) | endif
6674
if g:vimide_manage_misc_settings | call vimide#setMiscSettings(a:setGlobal) | endif
6775
let s:VIMIDE_BOOT_FINISHED = 1
6876
endif
@@ -73,6 +81,16 @@ function! vimide#boot(setGlobal) " {{{
7381

7482
endfunction " }}}
7583

84+
function! vimide#setVimEncodingSettings(setGlobal) "{{{
85+
if a:setGlobal
86+
set encoding=utf-8
87+
set termencoding=utf-8
88+
else
89+
setlocal encoding=utf-8
90+
setlocal termencoding=utf-8
91+
endif
92+
endfunction "}}}
93+
7694
function! vimide#setIndentSettings(setGlobal) "{{{
7795
if a:setGlobal
7896
set autoindent
@@ -202,6 +220,21 @@ function! vimide#setAirlineSettings(setGlobal) "{{{
202220
endif
203221
endfunction "}}}
204222

223+
function! vimide#setIndentLineSettigns(setGlobal) "{{{
224+
" can manage indentonly globally
225+
if a:setGlobal
226+
let g:indentLine_char = ''
227+
let g:indentLine_color_gui = '#000000'
228+
nnoremap <silent> <C-K><C-I> :IndentLinesToggle<CR>
229+
" let g:indentLine_char = '⎥' straigh line
230+
" let g:indentLine_char = '⎸' (needs FreeSerif)
231+
else
232+
" TODO: add BufferEnter/Exit logic to toggle indentLine only in elixir
233+
" buffers
234+
let pass = 1
235+
endif
236+
endfunction "}}}
237+
205238
function! vimide#setFoldsSettings(setGlobal) "{{{
206239
if a:setGlobal
207240
com! VimIDEToggleFold call vimide#toggleFold()
@@ -268,6 +301,29 @@ function! vimide#setCommentShortcuts(setGlobal) " {{{
268301
endif
269302
endfunction " }}}
270303

304+
function! vimide#setTabularizeShortcuts(setGlobal) " {{{
305+
" ####################################################################
306+
" Integration with Tabularize
307+
308+
if a:setGlobal
309+
" tabularize both => and =
310+
map <Leader>= =:Tabularize /=><CR>
311+
map <Leader>eq =:Tabularize /=/<CR>
312+
" tabularize case clauses
313+
map <Leader>- =:Tabularize /-><CR>
314+
" tabularize : in hashmaps and similar
315+
map <Leader>: =:Tabularize /\v(:)@<=\s/l0<CR>
316+
else
317+
" tabularize both => and =
318+
map <buffer> <Leader>= =:Tabularize /=><CR>
319+
map <buffer> <Leader>eq =:Tabularize /=/<CR>
320+
" tabularize case clauses
321+
map <buffer> <Leader>- =:Tabularize /-><CR>
322+
" tabularize : in hashmaps and similar
323+
map <buffer> <Leader>: =:Tabularize /\v(:)@<=\s/l0<CR>
324+
endif
325+
endfunction " }}}
326+
271327
function! vimide#setOtherShortcuts(setGlobal) " {{{
272328
let isGvim = has("gui_running")
273329
if a:setGlobal
@@ -279,6 +335,61 @@ function! vimide#setOtherShortcuts(setGlobal) " {{{
279335
noremap map ZZ :w<CR>:bd<CR>
280336
exec "noremap <silent> <C-X> :silent !" . g:vimide_terminal . "&<CR>"
281337
end
338+
339+
" general Tagbar integration
340+
" keyboard shortcuts
341+
nmap <F4> :TagbarToggle<CR>
342+
nmap <C-@> :CtrlPTagbar<CR>
343+
nmap <Leader>l :CtrlPLine<CR>
344+
345+
" save file like in `borland-ides`
346+
nmap <F2> :w<CR>
347+
imap <F2> <Esc>:w<CR>a
348+
349+
" lookup item under the cursor in file and show the list of
350+
" entries
351+
"
352+
" map ctrl-enter to jump to n-th match in list (gvim)
353+
map <C-CR> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
354+
" for vim
355+
map <Leader>;; [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
356+
357+
map <C-K><C-l> :exec 'match NonText /\<' . expand("<cword>") . '\>/'<CR>
358+
359+
" delete buffer and keep split
360+
" cannot have it local
361+
cab bdd bp\|bd #
362+
363+
" refactoring support
364+
map <C-K><C-w> :%s#\<<c-r><c-w>\>#
365+
map <C-K><C-a> :%s#\<<c-r><c-a>\>#
366+
367+
" -------------------------------------------------------
368+
" buffer management commands
369+
"
370+
" buffer switch commands for *normal* mode
371+
nmap <C-space><Left> :bN<CR>
372+
nmap <C-space><Right> :bn<CR>
373+
nmap <C-space><Down> :wa<CR>
374+
nmap <C-space><Up> :bd<CR>
375+
376+
" buffer switch commands for *insert* mode
377+
imap <C-space><Left> <Esc>:bN<CR>a
378+
imap <C-space><Right> <Esc>:bn<CR>a
379+
imap <C-space><Down> <Esc>:wa<CR>a
380+
imap <C-space><Up> <Esc>:bd<CR>a
381+
" mapping to allow keep Ctrl key presed when issuing commands
382+
map <C-Space><C-Left> <C-Space><Left>
383+
map <C-Space><C-Right> <C-Space><Right>
384+
map <C-Space><C-Down> <C-Space><Down>
385+
map <C-Space><C-Up> <C-Space><Up>
386+
387+
" list all buffers
388+
nmap <C-Space><Space> :buffers<CR>
389+
imap <C-Space><Space> <Esc>:buffers<CR>a
390+
map <C-Space><C-Space> <C-Space><Space>
391+
392+
map <F11> <C-space><Left>
282393
else
283394
noremap <buffer> <F3> :VimIDEToggleFold<CR>
284395
noremap <buffer> <silent> <Leader>trailing :call vimide#stripTrailingWhitespace()<CR>
@@ -288,15 +399,57 @@ function! vimide#setOtherShortcuts(setGlobal) " {{{
288399
noremap <buffer> map ZZ :w<CR>:bd<CR>
289400
exec "noremap <silent> <buffer> <C-X> :silent !" . g:vimide_terminal . "&<CR>"
290401
end
402+
403+
" general Tagbar integration
404+
" keyboard shortcuts
405+
nmap <buffer> <F4> :TagbarToggle<CR>
406+
nmap <buffer> <C-@> :CtrlPTagbar<CR>
407+
nmap <buffer> <Leader>l :CtrlPLine<CR>
408+
409+
" save file like in `borland-ides`
410+
nmap <buffer> <F2> :w<CR>
411+
imap <buffer> <F2> <Esc>:w<CR>a
412+
413+
" lookup item under the cursor in file and show the list of
414+
" entries
415+
"
416+
" map ctrl-enter to jump to n-th match in list (gvim)
417+
map <buffer> <C-CR> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
418+
" for vim
419+
map <buffer> <Leader>;; [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
420+
421+
map <buffer> <C-K><C-l> :exec 'match NonText /\<' . expand("<cword>") . '\>/'<CR>
422+
endif
423+
endfunction " }}}
424+
425+
function! vimide#setHackFont(setGlobal) " {{{
426+
let isGvim = has("gui_running")
427+
if a:setGlobal && isGvim
428+
set guifont=Hack\ 10
429+
430+
map <Leader>--- :set guifont=Ubuntu\ Mono\ 9<CR>
431+
map <Leader>-- :set guifont=Ubuntu\ Mono\ 10<CR>
432+
map <Leader>0 :set guifont=Hack\ 10<CR>
433+
map <Leader>++ :set guifont=Hack\ 11<CR>
434+
map <Leader>+++ :set guifont=Hack\ 12<CR>
291435
endif
292436
endfunction " }}}
293437

294438
function! vimide#setMiscSettings(setGlobal) " {{{
295439
"let isGvim = has("gui_running")
296440
if a:setGlobal
297441
set updatetime=500
442+
set wildignore=*.o,*.obj,*.beam,*.swp
298443
"TODO: set guioptions-=T "remove toolbar until we know what useful buttons put
299444
"on it ;-)
445+
set backspace=indent,eol,start
446+
set showmatch
447+
set matchtime=2
448+
else
449+
setlocal wildignore=*.o,*.obj,*.beam,*.swp
450+
setlocal backspace=indent,eol,start
451+
setlocal showmatch
452+
setlocal matchtime=2
300453

301454
endif
302455
endfunction " }}}

ftplugin/elixir.vim

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -121,29 +121,6 @@ let g:tagbar_type_elixir = {
121121
\ ]
122122
\ }
123123

124-
125-
" general Tagbar integration
126-
" keyboard shortcuts
127-
nmap <F4> :TagbarToggle<CR>
128-
nmap <C-@> :CtrlPTagbar<CR>
129-
nmap <Leader>l :CtrlPLine<CR>
130-
131-
132-
" ####################################################################
133-
" Integration with Tabularize
134-
135-
136-
" tabularize both => and =
137-
map <Leader>= =:Tabularize /=><CR>
138-
map <Leader>eq =:Tabularize /=/<CR>
139-
" tabularize case clauses
140-
map <Leader>- =:Tabularize /-><CR>
141-
" tabularize hashmaps and similar
142-
map <Leader>: =:Tabularize /\v(:)@<=\s/l0<CR>
143-
144-
145-
146-
147124
" ####################################################################
148125
" Elixir commenting/uncommenting shortcuts
149126

@@ -167,31 +144,6 @@ map <Leader>: =:Tabularize /\v(:)@<=\s/l0<CR>
167144
"imap <C-k><C-[> <C-k>[
168145
"imap <C-k><C-]> <C-k>]
169146

170-
171-
set wildignore=*.o,*.obj,*.beam,*.swp
172-
173-
" save file like in `borland-ides`
174-
nmap <F2> :w<CR>
175-
imap <F2> <Esc>:w<CR>a
176-
177-
" refactoring support
178-
map <C-K><C-w> :%s#\<<c-r><c-w>\>#
179-
map <C-K><C-a> :%s#\<<c-r><c-a>\>#
180-
181-
" lookup item under the cursor in file and show the list of
182-
" entries
183-
"
184-
" map ctrl-enter to jump to n-th match in list (gvim)
185-
map <C-CR> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
186-
" for vim
187-
map <Leader>;; [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
188-
189-
map <C-K><C-l> :exec 'match NonText /\<' . expand("<cword>") . '\>/'<CR>
190-
191-
192-
" delete buffer and keep split
193-
cab bdd bp\|bd #
194-
195147
" cross reference
196148
"
197149
" mix xref callers Mod

0 commit comments

Comments
 (0)