如何在 Vim 中永久显示当前文件的路径? [英] How can I permanently display the path of the current file in Vim?

查看:94
本文介绍了如何在 Vim 中永久显示当前文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 CTRLg 显示您正在处理的当前文件.有没有办法修改我的 .vimrc 以便始终显示文件名/路径?

I know CTRLg displays the current file you're working on. Is there a way to modify my .vimrc such that the filename/path is always displayed?

推荐答案

在您的状态行中,添加一个 %F 以显示完整路径:

In your statusline, add a %F to display the full path:

:help statusline

" Add full file path to your existing statusline
set statusline+=%F

注意,%F 将是完整路径.要获取相对于工作目录的路径,请使用 %f.

Note, %F will be the full path. To get a path relative to the working directory, use %f.

如果您的状态行不可见,您可能首先需要通过 laststatus=2

If your statusline is not already visible, you may first need to configure it to be always visible, via laststatus=2

set laststatus=2

有关选项的含义,请参阅 :help laststatus.通常,除非打开多个缓冲区,否则状态行可能会隐藏或隐藏,但我发现始终使用这样的自定义非常有用,值得为此放弃一个屏幕行保留.

See :help laststatus for what the options mean. Normally, the statusline may be hidden, or hidden unless multiple buffers are open, but I find it extremely useful to have on all the time with customizations like this, well worth giving up one screen line reserve for it.

这篇关于如何在 Vim 中永久显示当前文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆