Changing default position of quickfix window in Vim

雨燕双飞 提交于 2020-01-20 18:27:32

问题


Setup - MacVim with MiniBufExplorer plugin window spanning the entire top and Taglist plugin window on the right

Due to the fact that I keep my Taglist on the right, whenever I open the quickfix window, its position is on the far right, below the Taglist window (with the same width as the Taglist window)

Is it possible to change the default opening position logic so that the quickfix window will open below my main code window (down and left) or maybe span the entire bottom?


回答1:


While it is likely not possible to change default split-window behaviour of the :copen command, one can approach the issue in two ways.

The first way is to use the commands that directly alter window splitting directions (see :help :vertical and below until the "Closing a window" paragraph).

For instance, consider

:botright copen

or

:botright cwindow

to make the quickfix window open as the bottommost one1, or even

:vertical topleft cwindow

to open it to the top left of the current window.

The second approach is to move the quickfix window to the bottom of the window layout using an auto-command.

:autocmd FileType qf wincmd J

This trigger takes advantage of the fact that the quickfix window can be easily distinguished by its file-type, qf. The wincmd J command is equivalent to the Ctrl+W, Shift+J shortcut telling Vim to move a window to the very bottom (see :help :wincmd and :help ^WJ).


1 These commands could be shortened to :bo cope and :bo cw respectively. Also, one can create a short mapping or a custom command for their quick invocation.




回答2:


By default, Vim opens the new window above the current one for horizontal splits, and to the left of the current one for vertical splits (:help opening-window). You can customize this behavior like most other things in Vim:

make the new window appear below the current window.

:set splitbelow

make the new window appear on the right.

:set splitright


来源:https://stackoverflow.com/questions/6726783/changing-default-position-of-quickfix-window-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!