Skip to content

Commit e53baaa

Browse files
committed
Merge pull request #23 from vitalk/repeatable-plugs
Repeatable plugs
2 parents 5c3fcd0 + da267bb commit e53baaa

File tree

2 files changed

+54
-35
lines changed

2 files changed

+54
-35
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Simple TODO in Vim
1+
# Simple todo in Vim
22

33
May be this is the smallest Vim plugin in the world. It adds some useful
4-
mappings for manage simple TODO lists (example below) and nothing more.
4+
mappings for manage simple todo lists (example below) and nothing more.
55

66
```
77
[x] Create plugin
@@ -10,10 +10,22 @@ mappings for manage simple TODO lists (example below) and nothing more.
1010
[ ] Spread the word
1111
```
1212

13-
Plugin supports [GitHub-like task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments) as well.
13+
## Features
1414

15-
- [x] Support markdown list markers
16-
+ [x] So it's easy to create tasks in issues or pull requests on GitHub
15+
- Support [GitHub-like task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments):
16+
17+
- [x] Works well with different markdown list markers, e.g. `-`, `+`, `*`.
18+
+ [x] So it's easy to create tasks in issues or pull requests on GitHub
19+
20+
- Each mapping is repeatable via <kbd>.</kbd> (require [tpope/repeat](https://github.com/tpope/vim-repeat)).
21+
22+
- Tick symbol is configurable, e.g.
23+
24+
```
25+
[y] Water
26+
[y] Bread
27+
[ ] Milk
28+
```
1729

1830
## Installation
1931

@@ -66,6 +78,7 @@ imap <c-i> <Plug>(simple-todo-new)
6678
See `:help simple-todo-maps` for list of available <Plug> mappings.
6779

6880
You can also change the tick symbol to something else. Default is `x`.
81+
6982
```vim
7083
let g:simple_todo_tick_symbol = 'y'
7184
```

plugin/simple-todo.vim

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,57 @@ endfu " }}}
3333
" Public API {{{
3434

3535
" Create a new item
36-
nnore <Plug>(simple-todo-new) i[ ]<space>
37-
inore <Plug>(simple-todo-new) [ ]<space>
36+
nnore <silent> <Plug>(simple-todo-new) i[ ]<space>
37+
inore <silent> <Plug>(simple-todo-new) [ ]<space>
3838

3939
" Create a new item at the start of this line
40-
inore <Plug>(simple-todo-new-start-of-line) <Esc>mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4la
41-
nnore <Plug>(simple-todo-new-start-of-line) mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4l
42-
vnore <Plug>(simple-todo-new-start-of-line) I<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
40+
inore <silent> <Plug>(simple-todo-new-start-of-line) <Esc>mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4la
41+
nnore <silent> <Plug>(simple-todo-new-start-of-line) mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4l
42+
vnore <silent> <Plug>(simple-todo-new-start-of-line) I<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
4343

4444
" Create a new item below
45-
nnore <Plug>(simple-todo-below) o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
46-
inore <Plug>(simple-todo-below) <Esc>o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
45+
nnore <silent> <Plug>(simple-todo-below) o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
46+
inore <silent> <Plug>(simple-todo-below) <Esc>o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
4747

4848
" Create a new item above
49-
nnore <Plug>(simple-todo-above) O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
50-
inore <Plug>(simple-todo-above) <Esc>O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
49+
nnore <silent> <Plug>(simple-todo-above) O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
50+
inore <silent> <Plug>(simple-todo-above) <Esc>O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
5151

5252
" Mark item under cursor as done
53-
nnore <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
54-
vnore <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
55-
inore <Plug>(simple-todo-mark-as-done) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
53+
nnore <silent> <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
54+
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-done)")<cr>
55+
vnore <silent> <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
56+
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-done)")<cr>
57+
inore <silent> <Plug>(simple-todo-mark-as-done) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
58+
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-done)")<cr>
5659

5760
" Mark as undone
58-
nnore <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
59-
vnore <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
60-
inore <Plug>(simple-todo-mark-as-undone) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
61+
nnore <silent> <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
62+
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-undone)")<cr>
63+
vnore <silent> <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
64+
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-undone)")<cr>
65+
inore <silent> <Plug>(simple-todo-mark-as-undone) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
66+
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-undone)")<cr>
6167

6268
" }}}
6369
" Key bindings {{{
6470

6571
if g:simple_todo_map_keys
66-
nmap <silent><Leader>i <Plug>(simple-todo-new)
67-
imap <silent><Leader>i <Plug>(simple-todo-new)
68-
imap <silent><Leader>I <Plug>(simple-todo-new-start-of-line)
69-
nmap <silent><Leader>I <Plug>(simple-todo-new-start-of-line)
70-
vmap <silent><Leader>I <Plug>(simple-todo-new-start-of-line)
71-
nmap <silent><Leader>o <Plug>(simple-todo-below)
72-
imap <silent><Leader>o <Plug>(simple-todo-below)
73-
nmap <silent><Leader>O <Plug>(simple-todo-above)
74-
imap <silent><Leader>O <Plug>(simple-todo-above)
75-
nmap <silent><Leader>x <Plug>(simple-todo-mark-as-done)
76-
vmap <silent><Leader>x <Plug>(simple-todo-mark-as-done)
77-
imap <silent><Leader>x <Plug>(simple-todo-mark-as-done)
78-
nmap <silent><Leader>X <Plug>(simple-todo-mark-as-undone)
79-
vmap <silent><Leader>X <Plug>(simple-todo-mark-as-undone)
80-
imap <silent><Leader>X <Plug>(simple-todo-mark-as-undone)
72+
nmap <Leader>i <Plug>(simple-todo-new)
73+
imap <Leader>i <Plug>(simple-todo-new)
74+
imap <Leader>I <Plug>(simple-todo-new-start-of-line)
75+
nmap <Leader>I <Plug>(simple-todo-new-start-of-line)
76+
vmap <Leader>I <Plug>(simple-todo-new-start-of-line)
77+
nmap <Leader>o <Plug>(simple-todo-below)
78+
imap <Leader>o <Plug>(simple-todo-below)
79+
nmap <Leader>O <Plug>(simple-todo-above)
80+
imap <Leader>O <Plug>(simple-todo-above)
81+
nmap <Leader>x <Plug>(simple-todo-mark-as-done)
82+
vmap <Leader>x <Plug>(simple-todo-mark-as-done)
83+
imap <Leader>x <Plug>(simple-todo-mark-as-done)
84+
nmap <Leader>X <Plug>(simple-todo-mark-as-undone)
85+
vmap <Leader>X <Plug>(simple-todo-mark-as-undone)
86+
imap <Leader>X <Plug>(simple-todo-mark-as-undone)
8187
endif
8288

8389
" }}}

0 commit comments

Comments
 (0)