vim将通过CLI打开的文件添加到:e history

Sua*_*uan 6 vim history file command-line-interface

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

Bir*_*rei 3

一种可能性:

au BufEnter * for f in argv() | call histadd( "cmd", "e " . f ) | endfor
Run Code Online (Sandbox Code Playgroud)

解释:

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.
Run Code Online (Sandbox Code Playgroud)

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