jez / vim-superman

Read Unix man pages faster than a speeding bullet!
http://blog.jez.io/2014/12/20/vim-as-a-man-page-viewer/
MIT License
191 stars 20 forks source link

Improve q mapping #21

Closed syyyr closed 2 years ago

syyyr commented 5 years ago

The mapping didn't seem to work for me, because another buffer-local mapping overrides it in vim's runtime files:

nnoremap <buffer> <silent> q :q<CR>

This is almost the same as my proposed change. However, in neovim, the command is more complicated and actually uses :close, which doesn't close the window if it's the last one and that is kind of annoying, if you don't want to continue using vim after reading the man page. On the other hand, if you don't intent to support neovim, this line might as well be deleted, because it does nothing (the buffer-local mapping takes precedence anyway).

syyyr commented 5 years ago

Output of :verbose map q Vim:

n  q           *@:q<CR>
        Last set from /usr/share/vim/vim81/ftplugin/man.vim line 39
   q           * :q<CR>
        Last set from ~/.local/share/nvim/site/pack/bundle/opt/vim-superman/plugin/superman.vim line 41

Neovim:

n  q           *@:lclose<CR><C-W>c                                                                                                                              
        Last set from /usr/share/nvim/runtime/ftplugin/man.vim
   q           * :q<CR>
        Last set from ~/.local/share/nvim/site/pack/bundle/opt/vim-superman/plugin/superman.vim
syyyr commented 2 years ago

I have switched to using MANPAGER, which removed the need for a man/vim plugin, so I'll be closing this PR. Feel free to use the code, if you want.