diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-10 10:04:59 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-10 10:04:59 +1200 |
commit | e894be29ab171ea96c55c149c6720cb7d6123df2 (patch) | |
tree | fcff5370386f6cdc7ee29d540198a32a26680574 | |
parent | Arrange abbreviations in columns (diff) | |
download | dotfiles-e894be29ab171ea96c55c149c6720cb7d6123df2.tar.gz dotfiles-e894be29ab171ea96c55c149c6720cb7d6123df2.zip |
Use strftime() for date printing
-rw-r--r-- | vim/vimrc | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1171,12 +1171,25 @@ nnoremap <Leader>C xnoremap <Leader>C \ :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>gv -" Leader,d inserts the local date (POSIX date) +" Set up a quick command-function pair to run a command with the UTC timezone, +" in this case, for my date-printing mappings. Is there a nicer way to do +" this? I couldn't find one. +" +function! UTC(command) abort + let tz = expand('$TZ') + let $TZ = 'UTC' + execute a:command + let $TZ = tz +endfunction +command -complete=command -nargs=1 UTC + \ call UTC(<q-args>) + +" Leader,d inserts the local date (RFC 2822) nnoremap <Leader>d - \ :read !date<CR> -" Leader,D inserts the UTC date (POSIX date) + \ :<C-U>put=strftime('%a, %d %b %Y %T %z')<CR> +" Leader,D inserts the UTC date (RFC 2822) nnoremap <Leader>D - \ :read !date -u<CR> + \ :<C-U>UTC put=strftime('%a, %d %b %Y %T %z')<CR> " Leader,e forces a buffer to be editable nnoremap <Leader>e |