将文件中的行数添加到vim状态栏

时间:2014-01-07 18:48:29

标签: vim

如何编辑状态栏以始终显示打开文件中的总行数?

看着vim-airline,但没有看到一个简单的方法。

3 个答案:

答案 0 :(得分:9)

set statusline =%1*\ %n\ %*            "buffer number
set statusline +=%5*%{&ff}%*            "file format
set statusline +=%3*%y%*                "file type
set statusline +=%4*\ %<%F%*            "full path
set statusline +=%2*%m%*                "modified flag
set statusline +=%1*%=%5l%*             "current line
set statusline +=%2*/%L%*               "total lines
set statusline +=%1*%4v\ %*             "virtual column number
set statusline +=%2*0x%04B\ %*          "character under cursor

vim statusline

这是我使用的颜色:

hi User1 guifg=#eea040 guibg=#222222
hi User2 guifg=#dd3333 guibg=#222222
hi User3 guifg=#ff66ff guibg=#222222
hi User4 guifg=#a0ee40 guibg=#222222
hi User5 guifg=#eeee40 guibg=#222222

答案 1 :(得分:2)

Example of statusline results

如果您想在默认航空公司状态栏中添加这一小额内容 您可以更新相应的航空公司,而不是撰写新的状态 部分。

在我的情况下,我添加了当前行号之后的总行数,如3/45

航空公司的当前行号是z,您可以查看 运行echom g:airline_section_z,它应该返回如下内容:

%3p%% %{g:airline_symbols.linenr}%#__accent_bold#%4l:%#__restore__#%3v

您可以对其进行更新,以包含总行号%L

的vim状态行代码

%3p%% %{g:airline_symbols.linenr}%#__accent_bold#%4l /%L :%#__restore__#%3v

我还将%#__restore__#稍微移回一点来制作当前的行号 唯一的事情是粗体。

%3p%% %{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#/%L:%3v

使用let g:airline_section_z = 'test string here'后跟:AirlineRefresh进行测试,直至找到正确的方式,然后将其粘贴到vimrc中:

function! AirlineInit() let g:airline_section_z = 'your string' endfunction autocmd VimEnter * call AirlineInit()

这显然是canonical这样做的方式......

答案 2 :(得分:0)

使用airline插件,通过将以下代码行添加到init.vim文件中,解决了此问题。如果您使用的是Vim而不是Neovim,请将它们放在vimrc文件中。

copying numba/tests/pycc_distutils_usecase/source_module.py -> build/lib.macosx-10.13-intel-2.7/numba/tests/pycc_distutils_usecase
    running build_ext
    building 'numba._dynfunc' extension
    C compiler: cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe

creating build/temp.macosx-10.13-intel-2.7
creating build/temp.macosx-10.13-intel-2.7/numba
compile options: '-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c'
cc: numba/_dynfuncmod.c
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.13-intel-2.7/numba/_dynfuncmod.o -o build/lib.macosx-10.13-intel-2.7/numba/_dynfunc.so
ld: in '/usr/local/lib/libunwind.dylib', file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libunwind.dylib for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: in '/usr/local/lib/libunwind.dylib', file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libunwind.dylib for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: Command "cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.13-intel-2.7/numba/_dynfuncmod.o -o build/lib.macosx-10.13-intel-2.7/numba/_dynfunc.so" failed with exit status 1

----------------------------------------
Command "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools, 
tokenize;__file__='/private/tmp/pip-build-mt0h4y/numba/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
install --record /tmp/pip-yCTE4v-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-mt0h4y/numba

The result of using the above code