代码之家  ›  专栏  ›  技术社区  ›  Drew LeSueur

如何在vim中显示正在处理的文件的文件名?

  •  124
  • Drew LeSueur  · 技术社区  · 15 年前

    8 回复  |  直到 9 年前
        1
  •  187
  •   smilingthax    15 年前

    :f ( :file )会做同样的事 <C-G> . :f! 将给出一个不受信任的版本(如果适用)。

        2
  •  65
  •   David Wolever    15 年前

    控制 + 会的。

    另外,我喜欢:

    set statusline="%f%m%r%h%w [%Y] [0x%02.2B]%< %F%=%4v,%4l %3p%% of %L"
    

    产生:

    foo.c [C] [0x23]<code/foo.c   1,   1   2% of 50
    

    % 将替换为当前文件名。例如:

    :!echo "current file: %"
    current file: foo.c
    Press ENTER or type command to continue
    
        3
  •  18
  •   Brian Clements    8 年前

    :help statusline

    这些命令可以放在.vimrc文件中,也可以在vim中以命令的形式输入,方法是在命令模式下键入“:”。

    首先,使用以下命令将last status设置为2:

    set laststatus=2

    set statusline=%f

    对于文件的完整路径,请使用%F。

        4
  •  5
  •   Ryan Le    7 年前

    :set title 在窗口标题栏中显示文件名。

        5
  •  3
  •   joelostblom    9 年前

    :echo resolve(expand('%:p'))
    

    通过将下面的行添加到 ~./vimrc

    set statusline +=%{resolve(expand('%:p'))}\ %*
    
        6
  •  2
  •   sean    6 年前

    为什么这么复杂?管制员-G负责

        7
  •  2
  •   cucujoidea    6 年前

    set statusline=%f%m%r%h%w\ [%Y]\ [0x%02.2B]%<\ %F%4v,%4l\ %3p%%\ of\ %L\ lines

    让它工作。阿尔索

    set laststatus=2

    被利用了。

        8
  •  1
  •   alpha_989 medmunds    7 年前

    我用神奇的 vimrc 来自amix: https://github.com/amix/vimrc

    它使用 lightline.vim

    amix/vimrc 这个插件负责大部分的定制工作,非常稳定,已经有1000多人测试过了,你可以通过查看github星的数量来检查。。以及不常见的问题。

    它的更新也相当频繁。

    P、 S:不是这两个插件的作者。。只是个粉丝:)

        9
  •  1
  •   Alex Fenwood Hughes    7 年前

    我还需要把这个放到我的.vimrc文件中:

    set noruler
    set laststatus=2
    

    set statusline="%f%m%r%h%w [%Y] [0x%02.2B]%< %F%=%4v,%4l %3p%% of %L" 在my.vimrc文件中,重新启动终端后,状态行显示正确。