Vim Tips Wiki
m (VIMRC moved to Show file modification time on status bar: Page moved by JohnBot to improve title)
(Insert TipProposed template + minor manual clean)
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=1472
 
|id=1472
  +
|previous=1470
|title=VIMRC
 
  +
|next=1483
|created=January 13, 2007 7:00
+
|created=January 13, 2007
 
|complexity=basic
 
|complexity=basic
  +
|author=
|author=Display File last modification time on status bar
 
 
|version=5.7
 
|version=5.7
 
|rating=18/13
 
|rating=18/13
  +
|category1=
|text=<pre>
 
  +
|category2=
set statusline=%&lt;%f%&lt;%{FileTime()}%&lt;%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
 
  +
}}
  +
Put in your [[vimrc]]:
  +
 
<pre>
 
set statusline=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
 
set rulerformat=%15(%c%V\ %p%%%)
 
set rulerformat=%15(%c%V\ %p%%%)
"set rulerformat=%&lt;%f%&lt;%{FileTime()}%&lt;%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
+
"set rulerformat=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
   
fu! FileTime()
+
function! FileTime()
let ext=tolower(expand("%:e"))
+
let ext=tolower(expand("%:e"))
let fname=tolower(expand('%&lt;'))
+
let fname=tolower(expand('%<'))
let filename=fname . '.' . ext
+
let filename=fname . '.' . ext
let msg=""
+
let msg=""
let msg=msg." ".strftime("(Modified %b,%d %y %H:%M:%S)",getftime(filename))
+
let msg=msg." ".strftime("(Modified %b,%d %y %H:%M:%S)",getftime(filename))
return msg
+
return msg
  +
endfunction
endf
 
   
fu! CurTime()
+
function! CurTime()
let ftime=""
+
let ftime=""
let ftime=ftime." ".strftime("%b,%d %y %H:%M:%S")
+
let ftime=ftime." ".strftime("%b,%d %y %H:%M:%S")
return ftime
+
return ftime
  +
endfunction
endf
 
</pre>}}
+
</pre>
 
== Comments ==
 
This gets the file's mtime on each update. Isn't this somewhat of an overkill?
 
 
'''Anonymous'''
 
, January 18, 2007 1:13
 
----
 
so cool
 
 
kbtrace AT yahoo.com
 
, January 15, 2007 3:22
 
----
 
this tips doesn't work for me in vom 7
 
 
anonym
 
, January 15, 2007 11:30
 
----
 
wow good tip :)
 
   
 
==Comments==
ernesto schutz
 
 
This gets the file's mtime on each update. Isn't that somewhat of an overkill?
   
eschuetz3128--AT--hotmail.com
 
, January 13, 2007 13:44
 
 
----
 
----
<!-- parsed by vimtips.py in 0.461694 seconds-->
 

Revision as of 03:53, 6 January 2010

Tip 1472 Printable Monobook Previous Next

created January 13, 2007 · complexity basic · version 5.7


Put in your vimrc:

set statusline=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
set rulerformat=%15(%c%V\ %p%%%)
"set rulerformat=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}

function! FileTime()
  let ext=tolower(expand("%:e"))
  let fname=tolower(expand('%<'))
  let filename=fname . '.' . ext
  let msg=""
  let msg=msg." ".strftime("(Modified %b,%d %y %H:%M:%S)",getftime(filename))
  return msg
endfunction

function! CurTime()
  let ftime=""
  let ftime=ftime." ".strftime("%b,%d %y %H:%M:%S")
  return ftime
endfunction

Comments

This gets the file's mtime on each update. Isn't that somewhat of an overkill?