显示当前缓冲区的个数

发布于 2024-10-30 11:00:19 字数 143 浏览 2 评论 0原文

我有一个简单的要求:我想显示我当前正在编辑的缓冲区的编号。 我不想输入 :buffers (或同等内容),但让这个数字与文件名、当前列信息等一起显示在我的状态栏中。

有什么方法可以做到这一点吗?内置帮助在这一点上没有多大指导意义。

I have a simple requirement: I want to display the number of the buffer I'm currently editing.
I don't want to type :buffers (or equivalent) but have this number show up in my status bar thingy along with the file name, current column information etc.

Is there any way to do this? Inbuilt help isn't very instructive on this point.

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

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

发布评论

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

评论(4

墟烟 2024-11-06 11:00:19

:h statusline 显示所需的每一点帮助。

我的 .vimrc 中有以下内容

" Status Line {  
        set laststatus=2                             " always show statusbar  
        set statusline=  
        set statusline+=%-10.3n\                     " buffer number  
        set statusline+=%f\                          " filename   
        set statusline+=%h%m%r%w                     " status flags  
        set statusline+=\[%{strlen(&ft)?&ft:'none'}] " file type  
        set statusline+=%=                           " right align remainder  
        set statusline+=0x%-8B                       " character value  
        set statusline+=%-14(%l,%c%V%)               " line, character  
        set statusline+=%<%P                         " file position  
"}  

:h statusline shows every bit of help required.

I have the following in my .vimrc

" Status Line {  
        set laststatus=2                             " always show statusbar  
        set statusline=  
        set statusline+=%-10.3n\                     " buffer number  
        set statusline+=%f\                          " filename   
        set statusline+=%h%m%r%w                     " status flags  
        set statusline+=\[%{strlen(&ft)?&ft:'none'}] " file type  
        set statusline+=%=                           " right align remainder  
        set statusline+=0x%-8B                       " character value  
        set statusline+=%-14(%l,%c%V%)               " line, character  
        set statusline+=%<%P                         " file position  
"}  
掌心的温暖 2024-11-06 11:00:19

要在不配置任何内容的情况下获得答案:

:echo bufnr('%')

To get the answer without configuring anything:

:echo bufnr('%')

信仰 2024-11-06 11:00:19

您需要在 statusline 设置中列出 %n。在 vim 中尝试 :help statusline

You need %n listed in your statusline setting. Try :help statusline in vim.

左岸枫 2024-11-06 11:00:19
set statusline=%!bufnr('%')

另请参阅 :help status-line

set statusline=%!bufnr('%')

Also see :help status-line

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