浏览代码

Make n/N work properly

For caveats see:

https://github.com/mhinz/vim-startify/issues/218#issuecomment-222962221

References #218.
Marco Hinz 9 年之前
父节点
当前提交
54ee02272c
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      autoload/startify.vim

+ 5 - 0
autoload/startify.vim

@@ -702,6 +702,11 @@ function! s:set_mappings() abort
   execute "nnoremap <buffer>". s:nowait_string ."<silent> <cr>          :call startify#open_buffers()<cr>"
   execute "nnoremap <buffer>". s:nowait_string ."<silent> <2-LeftMouse> :call startify#open_buffers()<cr>"
 
+  " Without these mappings n/N wouldn't work properly, since autocmds always
+  " force the cursor back on the index.
+  nnoremap <buffer><expr> n ' j'[v:searchforward].'n'
+  nnoremap <buffer><expr> N 'j '[v:searchforward].'N'
+
   for k in keys(s:entries)
     execute 'nnoremap <buffer><silent>'. s:entries[k].nowait s:entries[k].index
           \ ':call startify#open_buffers('. string(k) .')<cr>'