I want to add a function to my statusline by which I can display the total characters count of the current file.
:help statusline
showed me that F
referes to Full path to the file in the buffer
, and through a bit searching I got to know how I can display the output of a shell command. So i currently have these in .vimrc
:
set statusline+=%#lite#\ %o/%{DisplayTotalChars()}\
function! DisplayTotalChars()
let current_file = expand("%:F")
let total_chars = system('wc -c ' . current_file)
return total_chars
endfunction
This is what it displays now in the status line, whereas I only need the characters count not the file path to be displayed:
36/29488 /home/nino/scripts/gfp.py^@