Skip to content

Instantly share code, notes, and snippets.

@saihoooooooo
Created December 9, 2011 05:22
Show Gist options
  • Save saihoooooooo/1450303 to your computer and use it in GitHub Desktop.
Save saihoooooooo/1450303 to your computer and use it in GitHub Desktop.
Abbreviation of the datetime
iabbrev *datetime* <C-r>=strftime("%Y/%m/%d %H:%M:%S")<CR><C-R>=<SID>Eatchar('\s')<CR>
iabbrev *date* <C-r>=strftime("%Y/%m/%d")<CR><C-R>=<SID>Eatchar('\s')<CR>
iabbrev *time* <C-r>=strftime("%H:%M:%S")<CR><C-R>=<SID>Eatchar('\s')<CR>
function! s:Eatchar(pattern)
let l:c = nr2char(getchar(0))
return (l:c =~ a:pattern) ? '' : l:c
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment