vim/dot-vim/keybinds.vim 1.3 K raw
1
let mapleader = " "
2
3
noremap <leader>e :Ex<CR>
4
noremap <leader>h :noh<CR>
5
noremap <S-l> :bnext<CR>
6
noremap <S-h> :bprevious<CR>
7
noremap <leader>t :tabnext<CR>
8
noremap <leader>c :Bclose<cr>:tabclose<cr>gT
9
noremap <C-d> <C-d>zz
10
noremap <C-u> <C-u>zz
11
12
noremap <leader>q :e ~/buffer.md<CR>
13
14
noremap <C-j> <C-W>j
15
noremap <C-k> <C-W>k
16
noremap <C-h> <C-W>h
17
noremap <C-l> <C-W>l
18
19
" Spelling suggestions (requires fzf)
20
function! s:SpellReplace(word, choice) abort
21
  execute 'normal! ciw' . a:choice
22
  stopinsert
23
endfunction
24
25
function! s:SpellSuggest() abort
26
  let l:word = expand('<cword>')
27
  if empty(l:word)
28
    return
29
  endif
30
  call fzf#run(fzf#wrap({
31
        \ 'source': spellsuggest(l:word, 25),
32
        \ 'sink': function('s:SpellReplace', [l:word]),
33
        \ 'options': ['--prompt', 'Spelling: ' . l:word . '> ']
34
        \ }))
35
endfunction
36
37
nnoremap <silent> <leader>s :call <SID>SpellSuggest()<CR>
38
39
command! Bclose call <SID>BufcloseCloseIt()
40
function! <SID>BufcloseCloseIt()
41
    let l:currentBufNum = bufnr("%")
42
    let l:alternateBufNum = bufnr("#")
43
44
    if buflisted(l:alternateBufNum)
45
        buffer #
46
    else
47
        bnext
48
    endif
49
50
    if bufnr("%") == l:currentBufNum
51
        new
52
    endif
53
54
    if buflisted(l:currentBufNum)
55
        execute("bdelete! ".l:currentBufNum)
56
    endif
57
endfunction