After saving a file in Vim, I get the message at the bottom of the screen "fileName" 92L, 3554C written. Is there a way to show the time in this message?

2 Answers 2


I don't think you can change the string by itself but you can use an autocommand to echo the date:

augroup SAVING
    autocmd BufWritePost * echo strftime('%c')
augroup END

On my machine it shows something like that:

enter image description here

An autocommand allows you to execute a command when a given event happens. Here we use the event BufWritePost which is triggered when a buffer is written to a file. The command we use is echo strftime() which echos the result of strftime() which returns a formatted date and time, you can check the doc to change the formatting if needed.



Different approach: I have the save time as part of my statusline:

set statusline=%f               " filename relative to current $PWD
set statusline+=%h              " help file flag
set statusline+=%m              " modified flag
set statusline+=%r              " readonly flag
set statusline+=\ [%{&ff}]      " Fileformat [unix]/[dos] etc...
set statusline+=\ (%{strftime(\"%Y-%m-%d\ %H:%M\",getftime(expand(\"%:p\")))})  " last modified timestamp
set statusline+=%=              " Rest: right align
set statusline+=%l,%c%V         " Position in buffer: linenumber, column, virtual column
set statusline+=\ %P            " Position in buffer: Percentage

set laststatus=2

To be honest I once copied that from somewhere (maybe stackoverflow) and it stayed in my vimrc.

The option laststatus=2 always displays the statusline.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.