惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
IT之家
IT之家
C
Check Point Blog
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
F
Fortinet All Blogs
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
爱范儿
爱范儿
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
How Do I Show the Current File Path In Neovim?
2019-07-31 · via jdhao's digital space

I saw on StackExchange that someone asked about how to see the full path of current file in Vim. I think it would be helpful to write about how I do it.

Temporary solution#

To show the full path of current file, you can press {count}Ctrl-G, that is, a count bigger or equaling to 1, followed by Ctrl-G. If you press 1<C-G>, only the full path of the file will be shown. If you press a number bigger than 1, the buffer index of current file will also be shown. For more info, see :h Ctrl-G.

You can also use expand() function to see the full path of current file:

In the above command, % is special character which represents the name of current file. :p is a path modifier which is used to show the full path of the file. Please see the expand() doc on other types of path modifiers.

Permanent solution#

If you want to show the current file path permanently so that you can see its path whenever you like. A good place to put the file path is the title bar. In order to do that, you need to set the title and titlestring. Currently, I am using the following settings:

set title
set titlestring=%{hostname()}\ \ %F\ \ %{strftime('%Y-%m-%d\ %H:%M',getftime(expand('%')))}

It will show the hostname of Vim, then the complete path of the file and followed by last modified time of the file.

The titlestring is just a string. You can use pre-defined modifier to show the content of various variables and the results of various functions. It seems a bit complicated. But in fact, it is not so scary. It uses the same syntax as the statusline (see :h statusline).

In the above setting for titlestring, we first show the hostname of the Nvim using the hostname() function. %{} is a special modifier, which will evaluate the expression inside and subsititute the returned result as a string. %F is a modifier used to show the full path of the file. The getftime() function is used to show the last modified time of the current file. strftime() function is used to convert the time to pre-defined format, that is YYYY-mm-dd HH:MM.

The end result is something like the following