jalvesaq / R-Vim-runtime

Vim runtime scripts of file types that include R code
GNU General Public License v2.0
24 stars 28 forks source link

Update roxygen tags from R/{rd,namespace}.R #18

Closed jranke closed 7 years ago

jranke commented 7 years ago

By the way, @jalvesaq, what plugin/script/snippet are you using for updating the Last Change: timestamp?

jalvesaq commented 7 years ago

I use the following code to update the Last Change line:

" Based on: http://vim.wikia.com/wiki/Insert_current_date_or_time
function! LastModified()
  if &modified
    let i = 1
    let line = getline(1)
    while i < 30 && line !~ "Last Change:"
      let i += 1
      let line = getline(i)
    endwhile
    if line =~ "Last Change:"
      let curlang = v:lang
      language C
      let today = strftime("%a %b %d, %Y  %I:%M%p")
      exe "language " . curlang
      let line = substitute(line, '\(.*\)Last Change:\(\s*\).*', '\1Last Change:\2' . today, "")
      call setline(i, line)
    endif
  endif
endfun

autocmd BufWritePre *.vim call LastModified()