From 8599c4256087db96a9857e6b91d7a7fc6c21d8fc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 09:15:49 +1200 Subject: Arrange abbreviations in columns --- vim/vimrc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index bd66a019..949c1f7b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1393,12 +1393,12 @@ nnoremap \ :setlocal autoindent! autoindent? " Some useful abbreviations -inoreabbrev tr@ tom@sanctum.geek.nz -inoreabbrev tr/ - -" Things I almsot always type wrnog -inoreabbrev almsot almost -inoreabbrev wrnog wrong -inoreabbrev Fielding Feilding -inoreabbrev THe The -inoreabbrev THere There +inoreabbrev tr@ tom@sanctum.geek.nz +inoreabbrev tr/ + +" THe things I almsot always type wrnog +inoreabbrev almsot almost +inoreabbrev wrnog wrong +inoreabbrev Fielding Feilding +inoreabbrev THe The +inoreabbrev THere There -- cgit v1.2.3 From e894be29ab171ea96c55c149c6720cb7d6123df2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 10:04:59 +1200 Subject: Use strftime() for date printing --- vim/vimrc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index 949c1f7b..57c685f9 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1171,12 +1171,25 @@ nnoremap C xnoremap C \ :setlocal cursorcolumn! cursorcolumn?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() + +" Leader,d inserts the local date (RFC 2822) nnoremap d - \ :read !date -" Leader,D inserts the UTC date (POSIX date) + \ :put=strftime('%a, %d %b %Y %T %z') +" Leader,D inserts the UTC date (RFC 2822) nnoremap D - \ :read !date -u + \ :UTC put=strftime('%a, %d %b %Y %T %z') " Leader,e forces a buffer to be editable nnoremap e -- cgit v1.2.3 From bc6124c2dbaeb997abd418e5088583aa1c5d2b93 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 10:18:28 +1200 Subject: Factor out date printing into function --- vim/vimrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index 57c685f9..dfd09db0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1171,6 +1171,10 @@ nnoremap C xnoremap C \ :setlocal cursorcolumn! cursorcolumn?gv +" Print an RFC2822-compliant date string +command Date + \ put=strftime('%a, %d %b %Y %T %z') + " 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. @@ -1186,10 +1190,10 @@ command -complete=command -nargs=1 UTC " Leader,d inserts the local date (RFC 2822) nnoremap d - \ :put=strftime('%a, %d %b %Y %T %z') + \ :Date " Leader,D inserts the UTC date (RFC 2822) nnoremap D - \ :UTC put=strftime('%a, %d %b %Y %T %z') + \ :UTC Date " Leader,e forces a buffer to be editable nnoremap e -- cgit v1.2.3 From 577dd1d84ef4b39d661fded58276b177aa3692f8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 10:19:38 +1200 Subject: Rename Date() to PutDate() to make func clearer --- vim/vimrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index dfd09db0..3e7b4e0a 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1172,7 +1172,7 @@ xnoremap C \ :setlocal cursorcolumn! cursorcolumn?gv " Print an RFC2822-compliant date string -command Date +command PutDate \ put=strftime('%a, %d %b %Y %T %z') " Set up a quick command-function pair to run a command with the UTC timezone, @@ -1190,10 +1190,10 @@ command -complete=command -nargs=1 UTC " Leader,d inserts the local date (RFC 2822) nnoremap d - \ :Date + \ :PutDate " Leader,D inserts the UTC date (RFC 2822) nnoremap D - \ :UTC Date + \ :UTC PutDate " Leader,e forces a buffer to be editable nnoremap e -- cgit v1.2.3 From 58c7048f90f51e601dcae15162ee657f23c0e46f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 10:19:56 +1200 Subject: Document what appears to be a Vim v8.1 bug --- vim/vimrc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index 3e7b4e0a..6132dbc6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1179,6 +1179,11 @@ command PutDate " in this case, for my date-printing mappings. Is there a nicer way to do " this? I couldn't find one. " +" This presently seems to be broken in v8.1.1487; the timezone first chosen +" seems to 'stick' permanently. I haven't worked out why yet. Using the new +" getenv() and setenv() functions does not seem to fix it. It works fine in +" Debian GNU/Linux's packaged v8.0.x. +" function! UTC(command) abort let tz = expand('$TZ') let $TZ = 'UTC' -- cgit v1.2.3 From e3ab2e71499e0c0617579a74ddf16af64dfcf2ef Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 10:20:05 +1200 Subject: Inline a set-run-restore command triplet --- vim/vimrc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index 6132dbc6..a501bd88 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1186,9 +1186,7 @@ command PutDate " function! UTC(command) abort let tz = expand('$TZ') - let $TZ = 'UTC' - execute a:command - let $TZ = tz + let $TZ = 'UTC' | execute a:command | let $TZ = tz endfunction command -complete=command -nargs=1 UTC \ call UTC() -- cgit v1.2.3