在垂直分割窗口中打开Vim帮助

134

有没有办法让Vim帮助文档在垂直分割窗格中打开,而不是水平分割窗格中打开?

13个回答

2

这是为了完善@m42的答案所做的补充,但我在stackoverflow上还没有足够的声望来添加评论。

在.vimrc中添加nnoremap <C-H> :vert bo help

现在,在Normal模式下按Ctrl-H将进入Command模式,前缀打开帮助文件并在右侧垂直分割窗口中显示。 在配置行的末尾包括一个空格(help·<-- )以获得最佳效果。

此映射允许您仍然使用:help\ :h打开水平拆分窗口或循环查看之前的帮助命令历史记录而无需自动展开提示。


1
我选择了以下内容:
" Open help in a vertical split or a new tab. 
augroup my_help
    " Remove current group to avoid double runs
    autocmd! 
    " If a help buffer is opened then try to move it to the right. If now it
    " doesn't fit help text (78 chars) then move it to a new tab.
    autocmd BufEnter * if &filetype == 'help' | wincmd L | if winwidth(0) < 78 | wincmd T | endif | endif
augroup END

这在vim和neovim中都适用。

如果我重新打开帮助,FileType help 在neovim中不起作用,因为帮助缓冲区在neovim中仍然隐藏,而vim似乎卸载了它。


0

这是我使用的,取自docwhat的答案。您可以根据自己的喜好更改值。

function! MoveWindowToRightOrNewTab()
    if winwidth(0) < 165
        wincmd T
    else
        wincmd L
        vert resize 85
    endif
endfunction

" Open help in a vertical split or a new tab.
augroup HelpWindowOnRight
    " Remove current group to avoid double runs
    autocmd!
    " If a help buffer is opened then try to move it to the right. If now it
    " doesn't fit help text (80 chars) then move it to a new tab.
    autocmd FileType help call MoveWindowToRightOrNewTab()
augroup END


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接