在指定的分割中打开 .netrw 文件
这与超级用户的问题相同,但我觉得在这里有更好的机会得到回答,所以...
在 Vim 中,我有四个分割 - 两两 - 并且在左上角有一个 netrw 是打开的。有没有办法从右下分割、左下分割等位置的 netrw 打开文件?
This is the same question as on SuperUser, but I feel it has a better chance of being answered here, so ...
In Vim, I have four splits - two by two - and in the upper left one netrw is open. Is there a way to open a file from netrw in the lower right split, lower left, etc.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一些提示 https://superuser。 com/questions/377501/keep-cursor-in-netrw-window-when-browsing-files-in-vim
将其放入您的 .vimrc 中,
要配置垂直预览分割,然后当光标位于所需文件上方时,键入 p 打开预览窗口。要关闭窗口,请键入 CtrlWz。
vim 中用于表示在光标未移动到时打开的窗口的术语是“预览窗口”。要了解有关此内容的更多信息,请参阅
或仅
浏览目录以了解其他浏览命令和其他 netrw 功能。
there're some hints here https://superuser.com/questions/377501/keep-cursor-in-netrw-window-when-browsing-files-in-vim
Put this in your .vimrc,
to configure vertical preview splits, then when the cursor is over the desired file, type p to open a preview window. To close the window, type CtrlWz.
The term used in vim for a window that's opened without the cursor moving to it is a "preview window". To find out more about this, see
or just
and browse the table of contents for other browsing commands and other netrw features.
您可以设置
g:netrw_chgwin
变量以使netrw在特定窗口中打开文件。请参阅:因此,要使当前窗口成为 netrw 的目标,请在该窗口中键入以下内容:
另一种方法是在目标窗口中启动 netrw (
:E
),点击C< /code> 选择它进行编辑并使用
关闭 netrw。You can set the
g:netrw_chgwin
variable to make netrw open the files in a specific window. See:So to make the current window the target of netrw type this while you're in that window:
Another way is to launch netrw in the target window (
:E
), hitC
to select it for editing and close netrw with<c-o>
.为了将上述答案结合起来一些灵感:我将以下窗口配置与 netrw 一起使用(与 :let g:netrw_liststyle = 2 一起使用):
因此我可以从每个其他窗口直接转到 Netrw-split。然后我将其放入 .vimrc:
WinLeave 命令将全局 g:netrw_chgwin 变量设置为刚刚离开的窗口(除非我们位于 netrw-window 中)。因此,netrw 将在我访问它的窗口中打开任何文件,并且由于窗口布局,我可以从任何其他窗口访问 netrw。
autocmd“filetype”还用于在我访问 netrw 的窗口中创建一个新文件。对于这个 netrw 的 '%' 命令必须被覆盖:
使用在窗口 g:netrw_chgwin 中创建新文件的函数:
To bring above answers together some inspirations: I use the following window configuration together with netrw (together with :let g:netrw_liststyle = 2):
Thus I can go directly to Netrw-split from every other window. Then I put to my .vimrc:
The WinLeave command sets the global g:netrw_chgwin variable to the window just left (except if we are in the netrw-window). Thus netrw will open any file in the window from which I accessed it and due to the window layout I can access netrw from any other window.
The autocmd 'filetype' is used to also create a new file in the window from which I accessed netrw. For this netrw's '%' command has to be overwritten:
With a function creating the new file in window g:netrw_chgwin: