Skip to content

Commit c650c39

Browse files
committed
Merge branch 'dev'
2 parents 1fad3a4 + fbe56fa commit c650c39

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Plugin is automatically applied for files with `.todo` extension.
2929

3030
##### TODO Items
3131

32-
The sequence matching the expression '^ [ ] ' marks a line as a TODO list item.
32+
The sequence matching the expression '^\s\*[ ].\*' marks a line as a TODO list item.
3333

3434
###### Example
3535

@@ -45,7 +45,7 @@ The sequence matching the expression '^ [ ] ' marks a line as a TODO list item.
4545
* `:VimTodoListsCreateNewItem` - creates a new item in current line
4646
* `:VimTodoListsGoToNextItem` - go to the next item
4747
* `:VimTodoListsGoToPreviousItem` - go to the previous item
48-
* `:VimTodoListsToggleItem` - toggles the item
48+
* `:VimTodoListsToggleItem` - toggles the current item (or selected items in visual mode)
4949

5050
##### Default key mappings
5151

@@ -118,7 +118,13 @@ Changelog
118118

119119
#### 0.2.0
120120

121-
* Adds an option to configure custom key mappings
121+
* Added an option to configure custom key mappings
122+
123+
#### 0.3.0
124+
125+
* Added items toggling in visual mode
126+
* Improves work with indentations of list items
127+
* Fixed the error when trying to navigate the buffer that doesn't contain items
122128

123129
Credits
124130
-------

doc/vim-todo-lists.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*vim-todo-lists.txt* Version 0.2.0
1+
*vim-todo-lists.txt* Version 0.3.0
22
*vim-todo-lists*
33

44
Plugin for TODO lists management.
@@ -70,7 +70,8 @@ Commands
7070
* :VimTodoListsCreateNewItem - creates a new item in current line
7171
* :VimTodoListsGoToNextItem - go to the next item
7272
* :VimTodoListsGoToPreviousItem - go to the previous item
73-
* :VimTodoListsToggleItem - toggles the item
73+
* :VimTodoListsToggleItem - toggles the current item (or selected items
74+
in visual mode)
7475

7576

7677
Default key bindings
@@ -150,7 +151,13 @@ SOFTWARE.
150151

151152
0.2.0
152153

153-
* Adds an option to configure custom key mappings
154+
* Added an option to configure custom key mappings
155+
156+
0.3.0
157+
158+
* Added items toggling in visual mode
159+
* Improves work with indentations of list items
160+
* Fixed the error when trying to navigate the buffer that doesn't contain items
154161

155162
==============================================================================
156163
8. Credits *VimTodoListsCredits*

plugin/vim-todo-lists.vim

+13-11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function! VimTodoListsSetNormalMode()
5151
nunmap <buffer> j
5252
nunmap <buffer> k
5353
nnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
54+
vnoremap <buffer> <Space> :'<,'>VimTodoListsToggleItem<CR>
5455
noremap <buffer> <leader>e :silent call VimTodoListsSetItemMode()<CR>
5556
endfunction
5657

@@ -62,8 +63,9 @@ function! VimTodoListsSetItemMode()
6263
nnoremap <buffer> j :VimTodoListsGoToNextItem<CR>
6364
nnoremap <buffer> k :VimTodoListsGoToPreviousItem<CR>
6465
nnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
65-
noremap <buffer> <leader>e :silent call VimTodoListsSetNormalMode()<CR>
66+
vnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
6667
inoremap <buffer> <CR> <CR><ESC>:VimTodoListsCreateNewItem<CR>
68+
noremap <buffer> <leader>e :silent call VimTodoListsSetNormalMode()<CR>
6769
endfunction
6870

6971

@@ -91,8 +93,8 @@ endfunction
9193
" Moves te cursor to the next item
9294
function! VimTodoListsGoToNextItem()
9395
normal! $
94-
silent exec '/^ \[.\]'
95-
silent exec 'noh'
96+
silent! exec '/^\s*\[.\]'
97+
silent! exec 'noh'
9698
normal! f[
9799
normal! l
98100
endfunction
@@ -101,21 +103,21 @@ endfunction
101103
" Moves te cursor to the previous item
102104
function! VimTodoListsGoToPreviousItem()
103105
normal! 0
104-
silent exec '?^ \[.\]'
105-
silent exec 'noh'
106+
silent! exec '?^\s*\[.\]'
107+
silent! exec 'noh'
106108
normal! f[
107109
normal! l
108110
endfunction
109111

110112

111-
" Toggles todo item in list
113+
" Toggles todo list item
112114
function! VimTodoListsToggleItem()
113115
let l:line = getline('.')
114116

115-
if match(l:line, '^ \[ \] .*') != -1
116-
call setline('.', substitute(l:line, '^ \[ \] ', ' [X] ', ''))
117-
elseif match(l:line, '^ \[X\] .*') != -1
118-
call setline('.', substitute(l:line, '^ \[X\] ', ' [ ] ', ''))
117+
if match(l:line, '^\s*\[ \].*') != -1
118+
call setline('.', substitute(l:line, '^\(\s*\)\[ \]', '\1[X]', ''))
119+
elseif match(l:line, '^\s*\[X\] .*') != -1
120+
call setline('.', substitute(l:line, '^\(\s*\)\[X\]', '\1[ ]', ''))
119121
endif
120122

121123
endfunction
@@ -142,6 +144,6 @@ if !exists('g:vimtodolists_plugin')
142144
command! VimTodoListsCreateNewItem silent call VimTodoListsCreateNewItem()
143145
command! VimTodoListsGoToNextItem silent call VimTodoListsGoToNextItem()
144146
command! VimTodoListsGoToPreviousItem silent call VimTodoListsGoToPreviousItem()
145-
command! VimTodoListsToggleItem silent call VimTodoListsToggleItem()
147+
command! -range VimTodoListsToggleItem silent <line1>,<line2>call VimTodoListsToggleItem()
146148
endif
147149

0 commit comments

Comments
 (0)