I do this for opening help pages in vertical window:
cabbrev help vert botright help
this way, it is ok, but a bit disturbing, and it is spamming my :history
开发者_如何学Pythona bit too.
I would like to get Vim to not expand this, just run the command. So when I write :help topic
I want it to not expanded, but to run the command :vert botright help topic
I tried with
cabbrev <silent> help vert botright help
but it doesn't work.
Is it possible to do at all?
I found the perfect solution based on this e-mail:
http://vim.1045645.n5.nabble.com/Horizontal-layout-by-default-td1164876.html#a1164886
So if you want help windows on the right, do this:
autocmd FileType help :wincmd H
this puts the 'help'
type windows immediately to the right just like CTRL-W H
. See :h CTRL-W_H
in vim.
The small problem with it if you have the hidden
option enabled, just closing the window with :q
doesn't unload the help window buffer, and if you want to open it again, it will not trigger the FileType event for some reason (why?), so if you use :set hidden
you need to:
autocmd FileType help set bufhidden=unload
to get help windows unload, which is the default behavior anyway.
It will only expand after you press another key (e.g. Space)
Perhaps you can make it
cabbrev <silent> he vert botright help
And then make it a habit to quickly say :he
SpaceEnter or indeed
:he topic
Which will then expand to the full command
Edit
If you don't want the expansion at all, I suggest a custom command:
:command! Help vert botright help
Although your answer works to see two help topics on the same window (e.g.: :h bar | h foo
), it is not optimal to see two entries on different windows (e.g.: h foo | sp | wincmd w | h bar
), as it executes also executes the wincmd
on the second window thus leaving three vertical windows, even if your monitor can display only two 80 columns windows.
Adding the following lines to ~/.vim/ftplugin/help.vim
executes the wincmd
only when there is room for another vertical split.
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
if min(map(range(winnr('$')), 'winwidth(v:val)')) > 160
wincmd L
endif
精彩评论