summaryrefslogtreecommitdiff
path: root/plugin/general/mappings.vim
blob: c8e13e1f2a847a97ab77283f77fe8dc90922703e (plain)
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
let mapleader = ","

" Easy ESC
inoremap <silent>jk <esc>
inoremap <silent>kj <esc>

" TAB in normal mode moves to the next quickfix entry
nnoremap <silent><tab> :bnext<cr>

" WINDOW AND BUFFER MANAGEMENT
nnoremap <leader>h :wincmd h<cr>
nnoremap <leader>j :wincmd j<cr>
nnoremap <leader>k :wincmd k<cr>
nnoremap <leader>l :wincmd l<cr>
nnoremap <C-h> :wincmd h<cr>
nnoremap <C-j> :wincmd j<cr>
nnoremap <C-k> :wincmd k<cr>
nnoremap <C-l> :wincmd l<cr>
nnoremap <leader>o :only<cr>
nnoremap <leader>c :close<cr>
nnoremap <leader>v :vsplit<cr>
nnoremap <leader>s :split<cr>
nnoremap <leader>d :bd!<cr>

" QUICKFIX LIST
nnoremap <C-j> :cnext<cr>
nnoremap <C-k> :cprev<cr>

" PLACEHOLDERS
nnoremap <leader><space> /<++><cr>ca<

" TERMINAL
tnoremap <esc> <c-\><c-n>
tnoremap jk <c-\><c-n>

" REGISTERS
nnoremap dD "_dd

" Make arrows useful in normal mode
nmap <down> ddp
nmap <up> ddkP
nmap <left> <nop>
nmap <right> <nop>

" Disable them in insert mode
imap <down> <nop>
imap <up> <nop>
imap <left> <nop>
imap <right> <nop>
vmap <down> <nop>
vmap <up> <nop>
vmap <left> <nop>
vmap <right> <nop>

" Make some room
nmap go o<esc>k
nmap gO O<esc>j

" Center the screen
nnoremap G Gzz
nnoremap n nzz
nnoremap N Nzz

" Useful remaps for line editing
nmap E gE
nmap L g$

" CUSTOM FUNCTIONS
nnoremap <silent><leader>w :Rg<cr>
nnoremap <silent><C-q> :call ToggleQuickfix()<cr>
nnoremap <silent><C-c> :call QuickMake()<cr>

" COMPLETION
inoremap <expr> <cr> pumvisible() ? "<C-y>" : "<cr>"
inoremap <expr> <C-c> pumvisible() ? "<C-e><esc>" : "<C-c>"
inoremap <expr> <tab> pumvisible() ? "<C-n>" : "<C-R>=CleverTab()<cr>"

" FILES
nnoremap <leader><leader> :FZF<cr>