如何检查终端中打开的文件名?也就是说,如何检查终端中现在打开了哪个文件?
现在每当我想查看文件名时,我都必须退出然后检查。有没有办法在终端中检查当前文件名?
答案1
要在 vi(m) 中查看文件名,请按esc,然后输入
:set title
文件名显示在终端窗口的顶部栏中。您还可以执行
:buffers
查看当前打开的文件 - 信息显示在终端底部。如果您打开了多个文件,您可以通过%a
当前文件旁边的显示来判断您当前在哪个文件中,例如
:buffers
1 %a= "unicorns" line 19
2 "rainbows" line 1
Press ENTER or type command to continue
答案2
我更喜欢 Ctrl-G:
http://vimdoc.sourceforge.net/htmldoc/editing.html
CTRL-G or *CTRL-G* *:f* *:fi* *:file*
:f[ile] Prints the current file name (as typed, unless ":cd"
was used), the cursor position (unless the 'ruler'
option is set), and the file status (readonly,
modified, read errors, new file). See the 'shortmess'
option about how to make this message shorter.
{Vi does not include column number}