Use j and k for navigating popup menu
dblume

dblume commited on 2022-12-16 00:19:30
Showing 1 changed files, with 4 additions and 7 deletions.

... ...
@@ -28,8 +28,10 @@ nnoremap j gj
28 28
 nnoremap k gk
29 29
 
30 30
 " From Steve Losh: http://learnvimscriptthehardway.stevelosh.com/chapters/10.html
31
-" Map jk to ESC in insert mode
32
-inoremap jk <esc>
31
+" Map jk to ESC in insert mode (except when navigating popup menu)
32
+inoremap <expr> jk pumvisible() ? '' : '<esc>'
33
+inoremap <expr> j pumvisible() ? '<Down>' : 'j'
34
+inoremap <expr> k pumvisible() ? '<Up>' : 'k'
33 35
 
34 36
 " https://stevelosh.com/blog/2010/09/coming-home-to-vim/#s3-why-i-came-back-to-vim
35 37
 nnoremap <leader>v <C-w>v<C-w>l
... ...
@@ -277,11 +279,6 @@ set omnifunc=syntaxcomplete#Complete
277 279
 " Omni completion via ctrl-space (in addition to ctrl-x ctrl-o)
278 280
 inoremap <Nul> <C-x><C-o>
279 281
 
280
-" Next two map j and k to C-n (next) and C-p (prev).
281
-" But it's affected by the 'jk to ESC' mapping above, so commented out.
282
-"inoremap <expr> j ((pumvisible())?("\<C-n>"):("j"))
283
-"inoremap <expr> k ((pumvisible())?("\<C-p>"):("k"))
284
-
285 282
 " cscope
286 283
 if has("cscope")
287 284
     set cscopetag  " Use both cscope and ctag for 'ctrl-]'
288 285