vim 将通过 CLI 打开的文件添加到 :e 历史记录

发布于 2024-12-22 06:44:10 字数 139 浏览 7 评论 0原文

默认情况下,在 Vim 中,当您输入 :e 并点击向上箭头时,它会显示之前使用 :e 命令打开的文件列表。有没有办法将我通过 vim从终端打开的文件也添加到此列表中?

In Vim by default when you enter :e and hit the up arrow, it shows a list of files previously opened using the :e command. Is there a way to add files that I've opened from the terminal via vim <filename> to this list as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吃兔兔 2024-12-29 06:44:10

一种可能性:

au BufEnter * for f in argv() | call histadd( "cmd", "e " . f ) | endfor

说明:

au                                # Autocommand.
BufEnter                          # Run it after entering a buffer.
*                                 # For any file matching.
for f in argv()                   # Select files in argument list.
call histadd( "cmd", "e " . f )   # Append to history of ex commands (beginning 
                                  # with colon) letter 'e' (of edit) with file name.
endfor                            # Repeat next loop.

将该命令放入您的 vimrc 文件中并尝试。

One possibility:

au BufEnter * for f in argv() | call histadd( "cmd", "e " . f ) | endfor

Explanation:

au                                # Autocommand.
BufEnter                          # Run it after entering a buffer.
*                                 # For any file matching.
for f in argv()                   # Select files in argument list.
call histadd( "cmd", "e " . f )   # Append to history of ex commands (beginning 
                                  # with colon) letter 'e' (of edit) with file name.
endfor                            # Repeat next loop.

Put that command in your vimrc file and try.

时常饿 2024-12-29 06:44:10

我不这么认为。 :e 只是浏览您的内容的便捷方式
ex 命令的历史记录。它不特定于编辑命令。它就这样发生了
当您键入 ex 命令的开头时,历史记录将为
“过滤”到以相同字符开头的条目。

:args 命令将打印以下列表作为参数给出的文件
命令行,并且 :arge 将编辑文件并将其放入参数中
列表(如果还没有)。

或者,可以使用 :b 命令输入缓冲区(如果
您的缓冲区中仍然有该文件并且想要编辑它。

其中之一可能对您有帮助!

I don't think so. The :e <up> is just a convenient way of browsing your
history of ex commands. It's not specific to the edit command. It just happens
that when you type the beginning of an ex command, the history will be
"filtered" to the entries which begin with the same characters.

The :args command will print the list of files given as arguments in
the command-line, and :arge will edit a file and put it in the argument
list (if isn't already).

Alternatively, the :b command can be used to enter a buffer (in case
you still have the file in a buffer and want to edit it.

One of these might help you!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文