且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Vim 中更改 quickfix 窗口的默认位置?

更新时间:2022-12-04 17:18:09

虽然无法更改默认的拆分窗口行为在 :copen 命令中,可以通过两种方式解决问题.

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

1. 使用直接改变窗口分割方向的命令(请参阅 :help :vertical 及以下直到关闭窗口"段落).

1. Use the commands that directly alter window splitting directions (see :help :vertical and below until the "Closing a window" paragraph).

例如,考虑以下命令:

:botright copen

:botright cwindow

让quickfix窗口作为最底层的窗口打开,甚至:

to make the quickfix window open as the bottommost one, or even:

:vertical topleft cwindow

在当前窗口的左上角打开它.

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

这些命令可以分别缩写为:bocop:bo cw:vert to cw.此外,当然,您可以创建一个简短的映射或用于快速调用的自定义命令.

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

2. 或者,将 quickfix 窗口移到窗口底部使用自动命令进行布局:

2. Alternatively, move the quickfix window to the bottom of the window layout using an auto-command:

:autocmd FileType qf wincmd J

这个触发器利用了quickfix窗口可以可以通过其文件类型 qf 轻松区分.wincmd J 命令相当于[Ctrl+W,Shift+J]指示 Vim 将当前窗口移动到屏幕最底部(参见 :help :wincmd:help ^WJ).

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 sequence instructing Vim to move the current window to the very bottom of the screen (see :help :wincmd and :help ^WJ).