@@ -45,13 +45,54 @@ endfunction
45
45
46
46
" Sets mappings for faster item navigation and editing
47
47
function ! VimTodoListsSetItemMode ()
48
- nnoremap <buffer> o o [ ]
49
- nnoremap <buffer> O O [ ]
50
- nnoremap <buffer> j $/^ \[.\] <CR> :noh <CR> f f
51
- nnoremap <buffer> k 0?^ \[.\] <CR> :noh <CR> f f
52
- nnoremap <buffer> <Space> :silent call VimTodoListsToggleItem() <CR>
48
+ nnoremap <buffer> o :VimTodoListsCreateNewItemBelow <CR>
49
+ nnoremap <buffer> O :VimTodoListsCreateNewItemAbove <CR>
50
+ nnoremap <buffer> j :VimTodoListsGoToNextItem <CR>
51
+ nnoremap <buffer> k :VimTodoListsGoToPreviousItem <CR>
52
+ nnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
53
53
noremap <buffer> <leader> e :silent call VimTodoListsSetNormalMode()<CR>
54
- inoremap <buffer> <CR> <CR> [ ]
54
+ inoremap <buffer> <CR> <CR><ESC> :VimTodoListsCreateNewItem<CR>
55
+ endfunction
56
+
57
+
58
+ " Creates a new item above the current line
59
+ function ! VimTodoListsCreateNewItemAbove ()
60
+ normal ! O [ ]
61
+ startinsert !
62
+ endfunction
63
+
64
+
65
+ " Creates e new item below the current line
66
+ function ! VimTodoListsCreateNewItemBelow ()
67
+ normal ! o [ ]
68
+ startinsert !
69
+ endfunction
70
+
71
+
72
+ " Creates e new item in the current line
73
+ function ! VimTodoListsCreateNewItem ()
74
+ normal ! 0 i [ ]
75
+ startinsert !
76
+ endfunction
77
+
78
+
79
+ " Moves te cursor to the next item
80
+ function ! VimTodoListsGoToNextItem ()
81
+ normal ! $
82
+ silent exec ' /^ \[.\]'
83
+ silent exec ' noh'
84
+ normal ! f [
85
+ normal ! l
86
+ endfunction
87
+
88
+
89
+ " Moves te cursor to the previous item
90
+ function ! VimTodoListsGoToPreviousItem ()
91
+ normal ! 0
92
+ silent exec ' ?^ \[.\]'
93
+ silent exec ' noh'
94
+ normal ! f [
95
+ normal ! l
55
96
endfunction
56
97
57
98
@@ -84,5 +125,11 @@ if !exists('g:vimtodolists_plugin')
84
125
augroup end
85
126
86
127
" Defining plugin commands
128
+ command ! VimTodoListsToggleItem silent call VimTodoListsToggleItem ()
129
+ command ! VimTodoListsCreateNewItemAbove silent call VimTodoListsCreateNewItemAbove ()
130
+ command ! VimTodoListsCreateNewItemBelow silent call VimTodoListsCreateNewItemBelow ()
131
+ command ! VimTodoListsCreateNewItem silent call VimTodoListsCreateNewItem ()
132
+ command ! VimTodoListsGoToNextItem silent call VimTodoListsGoToNextItem ()
133
+ command ! VimTodoListsGoToPreviousItem silent call VimTodoListsGoToPreviousItem ()
87
134
endif
88
135
0 commit comments