-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_mappings.vim
113 lines (86 loc) · 2.95 KB
/
key_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
" insert blank lines without going into insert mode
nmap go o<esc>
nmap gO O<esc
" select the lines which were just pasted
nnoremap vv `[V`]>
" mapping the jumping between splits. Hold control while using vim nav.
nmap <C-j> <C-W>j
nmap <C-k> <C-W>k
nmap <C-h> <C-W>h
nmap <C-l> <C-W>l
" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$
" select the lines which were just pasted
nnoremap vv `[V`]
" clean up trailing whitespace
map <Leader>c :StripTrailingWhitespaces<cr>
" compress excess whitespace on current line
map <Leader>e :s/\v(\S+)\s+/\1 /<cr>:nohl<cr>
" delete all buffers
map <Leader>d :bufdo bd<cr>
" map spacebar to clear search highlight
nnoremap <Leader><space> :noh<cr>
" buffer resizing mappings (shift + arrow key)
nnoremap <S-Up> <c-w>+
nnoremap <S-Left> <c-w><<c-w><<c-w><
nnoremap <S-Right> <c-w>><c-w>><c-w>
" Multiple cursor
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = '<A-n>'
let g:multi_cursor_start_key = 'g<C-n>'
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
" NERDTree for project drawer
let NERDTreeHijackNetrw = 0
nmap <leader>g :NERDTreeToggle<CR>
nmap <leader>r :NERDTreeFind<CR>
" ALE
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" FZF
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
" map for file search
nmap <c-p> :Files<CR>
" Map test runner
nnoremap <Leader>s :TestNearest<CR>
nnoremap <Leader>f :TestFile<CR>
nnoremap <Leader>n :TestSuite<CR>
nnoremap <Leader>l :TestLast<CR>
nnoremap <Leader>g :TestVisit<CR>
"Avoid using arrows
nnoremap <Up> <Nop>
nnoremap <Down> <Nop>
nnoremap <Left> <Nop>
nnoremap <Rigth> <Nop>
"copy to clipboard
vmap <leader>d :!pbcopy<CR>
vmap <leader>y :w !pbcopy<CR><CR>
"functions
map <Leader>cd :call SearchForDeclarationCursor()<CR>
" Command to generate group_vars variable
map <Leader>gvc :%s/\(^\\|\(.*{{.*}}.*\)\@<=\).\{-}\($\\|.*{{.*}}.*\)\@=//g<CR>:%s/^\n//g<CR>
map <Leader>cn :%s/^\n//g
map <Leader>gv :let @a=""<CR>:%s/{ \zs.\{-}\ze\ /\=setreg('A', submatch(0), 'l')/g<CR>:%d _<CR>:pu a<CR>:0d _<CR>i:
" Map vim-go
nnoremap <Leader>fs :GoFillStruct<CR>
"Easier split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
"Search inside the file
nmap <C-s>f :BLines<CR>