Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do you write text on the status line with the filename, row and col number with vimscript?

Tags:

vim

Is there a way to programmatically write on the bar below vim windows? I'm referring to the bar which displays the filename, cursor row + column, and the percentage of the document above the bottom of the window.

like image 598
dan Avatar asked Dec 29 '22 04:12

dan


2 Answers

It is called the status line.

You can get more information by typing :help statusline.

This is the one I used which includes line and column at the bottom right.

set statusline=%f%m%r%h\ [%L]\ [%{&ff}]\ %y%=[%p%%]\ [line:%05l,col:%02v]   
                │ │ │ │    │       │      │    │           │       │  
                │ │ │ │    │       │      │    │           │       └─ column number  
                │ │ │ │    │       │      │    │           └─── line number  
                │ │ │ │    │       │      │    └── percentage in file  
                │ │ │ │    │       │      └── file type  
                │ │ │ │    │       └── file format (dos/unix)  
                │ │ │ │    └── total number of line in file  
                │ │ │ └── help flag  
                │ │ └── read only flag  
                │ └── modified flag : [+] if modified, [-] if not modifiable  
                └── relative`  

The rendering is not ideal but the options, which are starting with the %sign, are described from left to right as you go down. They are all described in help.

This is a pretty static configuration, if you are willing to use a vim-plugin, there are some like vim-airline that provides more advanced features like git integration.

like image 133
Xavier T. Avatar answered Jan 13 '23 13:01

Xavier T.


The information in that bar is set in the option statusline. You can set this from within a script by using let &statusline = just as you would any other vim option.

See :help statusline for more information.

like image 40
Randy Morris Avatar answered Jan 13 '23 13:01

Randy Morris