Skip to content

Commit 4a83147

Browse files
committed
Improves the work with indentations in list items (#6)
1 parent a5042c6 commit 4a83147

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

README.md

Lines changed: 5 additions & 1 deletion
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

@@ -120,6 +120,10 @@ Changelog
120120

121121
* Adds an option to configure custom key mappings
122122

123+
#### 0.3.0
124+
125+
* Improves work with indentations of list items
126+
123127
Credits
124128
-------
125129

doc/vim-todo-lists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ SOFTWARE.
152152

153153
* Adds an option to configure custom key mappings
154154

155+
0.3.0
156+
157+
* Improves work with indentations of list items
158+
155159
==============================================================================
156160
8. Credits *VimTodoListsCredits*
157161

plugin/vim-todo-lists.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ endfunction
9191
" Moves te cursor to the next item
9292
function! VimTodoListsGoToNextItem()
9393
normal! $
94-
silent exec '/^ \[.\]'
94+
silent exec '/^\s*\[.\]'
9595
silent exec 'noh'
9696
normal! f[
9797
normal! l
@@ -101,7 +101,7 @@ endfunction
101101
" Moves te cursor to the previous item
102102
function! VimTodoListsGoToPreviousItem()
103103
normal! 0
104-
silent exec '?^ \[.\]'
104+
silent exec '?^\s*\[.\]'
105105
silent exec 'noh'
106106
normal! f[
107107
normal! l
@@ -112,10 +112,10 @@ endfunction
112112
function! VimTodoListsToggleItem()
113113
let l:line = getline('.')
114114

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\] ', ' [ ] ', ''))
115+
if match(l:line, '^\s*\[ \].*') != -1
116+
call setline('.', substitute(l:line, '^\(\s*\)\[ \]', '\1[X]', ''))
117+
elseif match(l:line, '^\s*\[X\] .*') != -1
118+
call setline('.', substitute(l:line, '^\(\s*\)\[X\]', '\1[ ]', ''))
119119
endif
120120

121121
endfunction

0 commit comments

Comments
 (0)