diff options
author | David Beniamine <david.beniamine@tetras-libre.fr> | 2020-01-09 08:05:32 +0000 |
---|---|---|
committer | David Beniamine <david.beniamine@tetras-libre.fr> | 2020-01-09 08:05:32 +0000 |
commit | 11811d90a7693c8e92e5c00c36b4557d14b775a7 (patch) | |
tree | 661ef1c78aa4d561ab05d34dc59f34e25092dfec | |
parent | 84b5ae6413055cb886a2deb279a33925d2070c71 (diff) | |
parent | 550c956cdda80c0f7a3006ca48537d479450e769 (diff) | |
download | todo.txt-vim-11811d90a7693c8e92e5c00c36b4557d14b775a7.zip |
Merge branch 'master' into 'master'
Use abbreviations instead of maps in insert mode
See merge request dbeniamine/todo.txt-vim!35
-rw-r--r-- | README.markdown | 15 | ||||
-rw-r--r-- | doc/todo.txt | 20 | ||||
-rw-r--r-- | ftplugin/todo.vim | 7 |
3 files changed, 42 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown index 5ca3983..cd57b57 100644 --- a/README.markdown +++ b/README.markdown @@ -296,6 +296,21 @@ following to your vimrc: let g:Todo_txt_prefix_creation_date=1 +With insert mode maps on, typing `date<Tab>` or `due:` can feel like glitches +This is because vim wait for mappings before inserting the words to the buffer. +To prevent the glitches, abbreviations can be used instead of mappings. +To turn it on, add the following to your vimrc: + + let g:TodoTxtUseAbbrevInsertMode=1 + +Abbreviations uses word separator to expand the abbreviations, thus `<Tab>` +is unavailable on abbreviations. Turning abbreviations mode will change +`date<Tab>` mapping into `date:`. The resulting abbreviations would be: + ++ `date:` : (Insert mode) Insert the current date ++ `due:` : (Insert mode) Insert `due:` followed by the current date ++ `DUE:` : (Insert mode) Insert `DUE:` followed by the current date + ### Done diff --git a/doc/todo.txt b/doc/todo.txt index 468301e..a6925da 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -320,6 +320,26 @@ following to your vimrc: let g:Todo_txt_prefix_creation_date=1 < +With insert mode maps on, typing `date<Tab>` or `due:` can feel like glitches +This is because vim wait for mappings before inserting the words to the buffer. +To prevent the glitches, abbreviations can be used instead of mappings. +To turn it on, add the following to your vimrc: +> + let g:TodoTxtUseAbbrevInsertMode=1 +< + +Abbreviations use word separator to expand the abbreviations, thus `<Tab>` +is unavailable on abbreviations. Turning abbreviations mode will change +`date<Tab>` mapping into `date:`. The resulting abbreviations would be: + + `date:` : (Insert mode) Insert the current date + + `due:` : (Insert mode) Insert `due:` followed by the current date + + `DUE:` : (Insert mode) Insert `DUE:` followed by the current date + +For more information regarding abbreviations, see |abbreviations| + 7.4 Done *TodoTxt-Done* diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index abaad7b..4bc3cb9 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -61,10 +61,17 @@ if !exists("g:Todo_txt_do_not_map") || ! g:Todo_txt_do_not_map noremap <script> <silent> <buffer> <localleader>c :call todo#PrioritizeAdd('C')<CR> " Insert date {{{3 +if get(g:, "TodoTxtUseAbbrevInsertMode", 0) + inoreabbrev <script> <silent> <buffer> date: <C-R>=strftime("%Y-%m-%d")<CR> + + inoreabbrev <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR> + inoreabbrev <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR> +else inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR> inoremap <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR> inoremap <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR> +endif noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR> |