Skip to content

Commit 5c9bf53

Browse files
Adds :itoday: and :inow: abbreviations (#450)
1 parent 38fb73c commit 5c9bf53

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

DOCS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,9 @@ Some content [[|
10541054
`org` buffers have access to two abbreviations:
10551055

10561056
* `:today:` - expands to today's date (example: `<2021-06-29 Tue>`)
1057+
* `:itoday:` - expands to an invactive version of today's date (example: `[2021-06-29 Tue]`)
10571058
* `:now:` - expands to today's date and current time (example: `<2021-06-29 Tue 15:32>`)
1059+
* `:inow:` - expands to invactive version of today's date and current time (example: `[2021-06-29 Tue 15:32]`)
10581060

10591061
## Formatting
10601062
Formatting is done via `gq` mapping, which uses `formatexpr` under the hood (see `:help formatexpr` for more info).

ftplugin/org.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ setlocal formatexpr=OrgmodeFormatExpr()
2626
setlocal foldlevel=0
2727
setlocal omnifunc=OrgmodeOmni
2828
setlocal commentstring=#\ %s
29-
inoreabbrev <silent><buffer> :today: <<C-R>=luaeval("require('orgmode.objects.date').today():to_string()")<CR>>
30-
inoreabbrev <silent><buffer> :now: <<C-R>=luaeval("require('orgmode.objects.date').now():to_string()")<CR>>
29+
inoreabbrev <silent><buffer> :today: <C-R>=luaeval("require('orgmode.objects.date').today():to_wrapped_string(true)")<CR>
30+
inoreabbrev <silent><buffer> :now: <C-R>=luaeval("require('orgmode.objects.date').now():to_wrapped_string(true)")<CR>
31+
32+
" The versions of the date abbreviations prefixed with 'i' produce inactive
33+
" dates and timestamps rather than active ones like the non-prefixed
34+
" abbreviations
35+
inoreabbrev <silent><buffer> :itoday: <C-R>=luaeval("require('orgmode.objects.date').today():to_wrapped_string(false)")<CR>
36+
inoreabbrev <silent><buffer> :inow: <C-R>=luaeval("require('orgmode.objects.date').now():to_wrapped_string(false)")<CR>
3137

3238
command! -buffer OrgDiagnostics lua require('orgmode.org.diagnostics').print()

0 commit comments

Comments
 (0)