(not sure about this tip, but improving it marginally) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
Line 4: | Line 4: | ||
|previous=738 |
|previous=738 |
||
|next=741 |
|next=741 |
||
− | |created= |
+ | |created=2004 |
|complexity=basic |
|complexity=basic |
||
|author=Bounga |
|author=Bounga |
||
Line 22: | Line 22: | ||
</pre> |
</pre> |
||
− | This is true for any option set using the < |
+ | This is true for any option set using the <code>:set</code> command. It is possible to work around this using single-quoted strings and the [[Set options or named registers with let|<code>let</code> command]]. |
==Comments== |
==Comments== |
Revision as of 05:45, 13 July 2012
created 2004 · complexity basic · author Bounga · version 6.0
I wanted to write a good looking statusline, grouping all the informations I need about a file and the environment. The needed things were the filename, the format of this file, its type, the position (line, column) of the cursor, the relative position in the file (%) and the date (day/month/year - hours:minutes).
There is one thing to always remember when you write a statusline. You have to escape all the blank characters and the " characters. To escape a character you have to use \, so if you want a whitespace you have to do "\ ".
Now here is the statusline:
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
This is true for any option set using the :set
command. It is possible to work around this using single-quoted strings and the let
command.
Comments
I think it is better
set statusline=%F%m%r%h%w\ (%{&ff}){%Y}[%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
Try this:
set statusline=%<%F%h%m%r%h%w%y\ %{&ff}\ %{strftime(\"%d/%m/%Y-%H:%M\")}%=\ col:%c%V\ ascii:%b\ pos:%o\ lin:%l\,%L\ %P
if you want above statusline appear when there is single window, try:
set laststatus=2
--- The status line is update on potentially *each* key stroke. So having a too dynamic modeline is going to make vim really slow.
To see the file modified time on status line
set statusline=%{strftime(\"%c\",getftime(expand(\"%:p\")))}
Here's the statusline I'm currently using:
set statusline=%<%F%h%m%r%h%w%y\ %{&ff}\ %{strftime(\"%c\",getftime(expand(\"%:p\")))}%=\ lin:%l\,%L\ col:%c%V\ pos:%o\ ascii:%b\ %P