aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-04-05 13:01:48 -0400
committerTeddy Wing2016-04-05 13:01:48 -0400
commitf41b57a0d1c76bb8810388734e4a9f0df2b8bc65 (patch)
treeeaf5d9a57a8367895a93c543980fa8c9d9eb2cd7
parent7c8b7aa91cc1dec48e79a65a201b7c5228203d2d (diff)
downloadvim-twodo-f41b57a0d1c76bb8810388734e4a9f0df2b8bc65.tar.bz2
Add ftplugin with mappings
Create some useful mappings for creating and marking TODO items. These will be buffer-local to *.todo files, which is why we're defining them in the ftplugin file.
-rw-r--r--ftplugin/todo.vim36
1 files changed, 36 insertions, 0 deletions
diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim
new file mode 100644
index 0000000..3009845
--- /dev/null
+++ b/ftplugin/todo.vim
@@ -0,0 +1,36 @@
+if exists("b:did_ftplugin")
+ finish
+endif
+let b:did_ftplugin = 1
+
+
+nnoremap <silent> <buffer> <Plug>TwodoNewTodoBelow o-
+nnoremap <silent> <buffer> <Plug>TwodoNewTodoAbove O-
+nnoremap <silent> <buffer> <Plug>TwodoMarkComplete m`:<c-u>s/\v^(\s*)- /\1v /<cr>``
+nnoremap <silent> <buffer> <Plug>TwodoMarkDeleted m`:<c-u>s/\v^(\s*)- /\1x /<cr>``
+nnoremap <silent> <buffer> <Plug>TwodoMarkPartiallyCompleted m`:<c-u>s/\v^(\s*)- /\1S /<cr>``
+nnoremap <silent> <buffer> <Plug>TwodoRemoveOldTodos :<c-u>g/^\s*[vSx] /d<cr>
+
+if !hasmapto('<Plug>TwodoNewTodoBelow') || !maparg('<leader>n', 'n')
+ nmap <silent> <buffer> <leader>n <Plug>TwodoNewTodoBelow
+endif
+
+if !hasmapto('<Plug>TwodoNewTodoAbove') || !maparg('<leader>N', 'n')
+ nmap <silent> <buffer> <leader>N <Plug>TwodoNewTodoAbove
+endif
+
+if !hasmapto('<Plug>TwodoMarkComplete') || !maparg('<leader>c', 'n')
+ nmap <silent> <buffer> <leader>c <Plug>TwodoMarkComplete
+endif
+
+if !hasmapto('<Plug>TwodoMarkDeleted') || !maparg('<leader>d', 'n')
+ nmap <silent> <buffer> <leader>d <Plug>TwodoMarkDeleted
+endif
+
+if !hasmapto('<Plug>TwodoMarkPartiallyCompleted') || !maparg('<leader>s', 'n')
+ nmap <silent> <buffer> <leader>s <Plug>TwodoMarkPartiallyCompleted
+endif
+
+if !hasmapto('<Plug>TwodoRemoveOldTodos') || !maparg('<leader>R', 'n')
+ nmap <silent> <buffer> <leader>R <Plug>TwodoRemoveOldTodos
+endif