-
Notifications
You must be signed in to change notification settings - Fork 4
/
emacs_cursor.vim
62 lines (53 loc) · 1.61 KB
/
emacs_cursor.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
if exists('g:loaded_emacs_cursor') || v:version < 702
finish
endif
let g:loaded_emacs_cursor = 1
let s:save_cpo = &cpoptions
set cpoptions&vim
function! s:pumvisible() abort
let l:Fn = get(g:, 'EmacsCursorPumvisible', v:null)
if l:Fn != v:null && l:Fn()
return v:true
endif
return pumvisible()
endfunction
inoremap <Plug>(emacs-enter) <Cmd>set eventignore+=InsertEnter,InsertLeave<CR>
inoremap <Plug>(emacs-leave) <Cmd>set eventignore-=InsertEnter,InsertLeave<CR>
imap <expr> <Plug>(emacs-down) <SID>pumvisible()
\ ? "\<Down>"
\ : "\<Plug>(emacs-enter)\<C-g>u\<C-o>gj\<Plug>(emacs-leave)"
imap <expr> <Plug>(emacs-up) <SID>pumvisible()
\ ? "\<Up>"
\ : "\<Plug>(emacs-enter)\<C-g>u\<C-o>gk\<Plug>(emacs-leave)"
inoremap <Plug>(emacs-eol) <C-g>u<C-o>g$
inoremap <expr> <Plug>(emacs-bol) col('.') == 2 ? "\<Left>" : "\<C-g>u\<C-o>g0"
inoremap <expr> <Plug>(emacs-kill) col('.') == col('$') ? "\<C-o>gJ" : "\<C-g>u\<C-o>d$"
nmap <C-c> <Esc>
nmap <C-j> <CR>
imap <C-c> <Esc>
imap <C-j> <CR>
imap <C-h> <BS>
imap <C-b> <Left>
imap <C-f> <Right>
imap <C-d> <Del>
imap <C-p> <Plug>(emacs-up)
imap <C-n> <Plug>(emacs-down)
imap <C-a> <Plug>(emacs-bol)
imap <C-e> <Plug>(emacs-eol)
imap <C-k> <Plug>(emacs-kill)
inoremap <C-t> <Esc>"0ylxa<C-r>0<Left>
cmap <C-h> <BS>
cmap <C-a> <Home>
cmap <C-b> <Left>
cmap <C-f> <Right>
cmap <C-d> <Del>
cnoremap <C-k> <C-\>e getcmdpos() == 1 ? '' : getcmdline()[:getcmdpos()-2]<CR>
cnoremap <expr> <C-c> pumvisible() ? "\<C-e>" : "\<C-c>"
smap <C-a> <C-g>I
smap <C-e> <C-g>A
smap <C-b> <C-g>I
smap <C-f> <C-g>A
smap <C-d> <Del>
smap <C-c> <Esc>
let &cpoptions = s:save_cpo
unlet s:save_cpo