Friday, July 8, 2011

RE: Vim statusline examples with screenshots?

From: François_Ingelrest, Fri, July 08, 2011 2:52 am
> On Fri, Jul 8, 2011 at 08:45, Bee wrote:
> >
> > > How do you get the file size? That's a useful information I
> > > could add to my own status line.
> >
> > :help line2byte()
>
> Cool thanks, I didn't know about that one.

You can tweak it a little to handle empty buffers and group numbers
(below
with US commas, change to taste).

1:function! Cream_statusline_bufsize()
2: let bufsize = line2byte(line("$") + 1) - 1
3: " prevent negative numbers (non-existant buffers)
4: if bufsize < 0
5: let bufsize = 0
6: endif
7: " add commas
8: let remain = bufsize
9: let bufsize = ""
10: while strlen(remain) > 3
11: let bufsize = ",".strpart(remain, strlen(remain) - 3).bufsize
12: let remain = strpart(remain, 0, strlen(remain) - 3)
13: endwhile
14: let bufsize = remain . bufsize
15: " too bad we can't use (nr2char(1068)) :)
16: let char = "b"
17: return bufsize . char
18:endfunction

We use an incorrect "b" to indicate bytes to better distinguish it
from numbers.


--
Steve Hall [ digitect dancingpaper com ]


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: