gpt4 book ai didi

vim: vnew,但接受缓冲区而不是文件名?

转载 作者:行者123 更新时间:2023-12-01 13:00:43 25 4
gpt4 key购买 nike

目前,如果我想创建一个新窗口然后加载一个缓冲区,我使用 :vnew :buf foo.py。是否有一个命令可以同时执行这两项操作?

最佳答案

是的,有一个命令:

:[N]sb[uffer] [N]                   :sb :sbuffer
Split window and edit buffer [N] from the buffer list. If [N]
is not given, the current buffer is edited. Respects the
"useopen" setting of 'switchbuf' when splitting. This will
also edit a buffer that is not in the buffer list, without
setting the 'buflisted' flag.

您可能会发现这些也很有用:

:[N]sbn[ext] [N]                                    :sbn :sbnext
Split window and go to [N]th next buffer in buffer list.
Wraps around the end of the buffer list. Uses 'switchbuf'

:[N]sbN[ext] [N] :sbN :sbNext :sbp :sbprevious
:[N]sbp[revious] [N]
Split window and go to [N]th previous buffer in buffer list.
Wraps around the start of the buffer list.
Uses 'switchbuf'.

这两个命令的问题是它们会水平分割。您可以在它们之前加上 :vert[ical],但这会破坏您的单一命令范式 :-)

总之,:vert sb foo.py 打字不多,如果你真的经常使用它,你可能要考虑为它创建一个映射。也许是这样的:

cnoremap ,sb vert sb 

关于vim: vnew,但接受缓冲区而不是文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6130747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com