Loading ...
Sorry, an error occurred while loading the content.

93813Re: time spent editing a file

Expand Messages
  • Ben Schmidt
    Aug 1, 2008
      Great teamwork, guys! Full marks for improving portability with
      reltime(). I don't really think the milliseconds (or whatever) are
      useful to display though. I honestly don't open, edit and save my files
      with measurement errors less than that, and it's just wasted space in
      the statusline or whatever. The 'pause the timer while using another
      app/window' is an interesting idea, too; would be interesting to see
      that in action.

      At any rate, it seems the approach that would work best with different
      viminfo settings etc. would be to use a BufWinEnter autocommand but set
      the variable only if not already set. We shouldn't need setbufvar if
      using that autocommand, either, so just this should suffice, I think
      (and doesn't need float support which a lot of people still won't have):

      augroup TimeSpentEditing
      au BufWinEnter * if !exists('b:tstart')|let b:tstart=reltime()|en
      augroup END

      func! TimeSpentEditing()
      let secs=str2nr(reltimestr(reltime(b:tstart)))
      let hours=secs/3600
      let minutes=(secs-hours*3600)/60
      let seconds=secs-hours*3600-minutes*60
      return printf("%d:%02d:%02d",hours,minutes,seconds)

      com! TimeSpentEditing echo TimeSpentEditing()
      map <silent> <leader>dt :TimeSpentEditing<CR>



      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 15 messages in this topic