Skip to content

Commit f4a2bd8

Browse files
committed
Add options to disable Tab/Alt indent/dedent mappings (issue #25)
Issue #25 on GitHub: Optionally disable tab indent/outdent of lists #25
1 parent ac3e0f5 commit f4a2bd8

File tree

4 files changed

+69
-25
lines changed

4 files changed

+69
-25
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ When you change the nesting level (indentation) of a line containing a bullet po
7373

7474
The first level of list items gets the first bullet point in `g:notes_list_bullets`, the second level gets the second, etc. When you're indenting a list item to a level where the `g:notes_list_bullets` doesn't have enough bullets, the plug-in starts again at the first bullet in the list (in other words the selection of bullets wraps around).
7575

76+
### The `g:notes_tab_indents` option
77+
78+
By default `Tab` is mapped to indent list items and `Shift-Tab` is mapped to dedent list items. You can disable these mappings by adding the following to your [vimrc script] [vimrc]:
79+
80+
:let g:notes_tab_indents = 0
81+
82+
### The `g:notes_alt_indents` option
83+
84+
By default `Alt-Right` is mapped to indent list items and `Alt-Left` is mapped to dedent list items. You can disable these mappings by adding the following to your [vimrc script] [vimrc]:
85+
86+
:let g:notes_alt_indents = 0
87+
7688
### The `g:notes_shadowdir` option
7789

7890
The notes plug-in comes with some default notes containing documentation about the plug-in. This option defines the path of the directory containing these notes.

autoload/xolox/notes.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
" Note: This file is encoded in UTF-8 including a byte order mark so
77
" that Vim loads the script using the right encoding transparently.
88

9-
let g:xolox#notes#version = '0.18'
9+
let g:xolox#notes#version = '0.18.1'
1010
let s:scriptdir = expand('<sfile>:p:h')
1111

1212
call xolox#misc#compat#check('notes', 2)
@@ -60,6 +60,14 @@ function! xolox#notes#init() " {{{1
6060
if !exists('g:notes_smart_quotes')
6161
let g:notes_smart_quotes = 1
6262
endif
63+
" Tab/Shift-Tab is used to indent/dedent list items by default.
64+
if !exists('g:notes_tab_indents')
65+
let g:notes_tab_indents = 1
66+
endif
67+
" Alt-Left/Alt-Right is used to indent/dedent list items by default.
68+
if !exists('g:notes_alt_indents')
69+
let g:notes_alt_indents = 1
70+
endif
6371
" Text used for horizontal rulers.
6472
if !exists('g:notes_ruler_text')
6573
let g:notes_ruler_text = repeat(' ', ((&tw > 0 ? &tw : 79) - 5) / 2) . '* * *'

doc/notes.txt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Contents ~
1313
4. The |g:notes_smart_quotes| option
1414
5. The |g:notes_ruler_text| option
1515
6. The |g:notes_list_bullets| option
16-
7. The |g:notes_shadowdir| option
17-
8. The |g:notes_indexfile| option
18-
9. The |g:notes_indexscript| option
19-
10. The |g:notes_tagsindex| option
16+
7. The |g:notes_tab_indents| option
17+
8. The |g:notes_alt_indents| option
18+
9. The |g:notes_shadowdir| option
19+
10. The |g:notes_indexfile| option
20+
11. The |g:notes_indexscript| option
21+
12. The |g:notes_tagsindex| option
2022
4. Commands |notes-commands|
2123
1. The |:Note| command
2224
2. The |:NoteFromSelectedText| command
@@ -215,6 +217,24 @@ indenting a list item to a level where the |g:notes_list_bullets| doesn't have
215217
enough bullets, the plug-in starts again at the first bullet in the list (in
216218
other words the selection of bullets wraps around).
217219

220+
-------------------------------------------------------------------------------
221+
The *g:notes_tab_indents* option
222+
223+
By default 'Tab' is mapped to indent list items and 'Shift-Tab' is mapped to
224+
dedent list items. You can disable these mappings by adding the following to
225+
your |vimrc| script:
226+
>
227+
:let g:notes_tab_indents = 0
228+
229+
-------------------------------------------------------------------------------
230+
The *g:notes_alt_indents* option
231+
232+
By default 'Alt-Right' is mapped to indent list items and 'Alt-Left' is mapped
233+
to dedent list items. You can disable these mappings by adding the following
234+
to your |vimrc| script:
235+
>
236+
:let g:notes_alt_indents = 0
237+
218238
-------------------------------------------------------------------------------
219239
The *g:notes_shadowdir* option
220240

ftplugin/notes.vim

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim file type plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: December 1, 2011
3+
" Last Change: May 5, 2013
44
" URL: http://peterodding.com/code/vim/notes/
55

66
if exists('b:did_ftplugin')
@@ -91,25 +91,29 @@ endif
9191
inoremap <buffer> *** <C-o>:call xolox#notes#insert_ruler()<CR>
9292
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ***"'
9393

94-
" Indent list items using <Tab> and <Shift-Tab>. {{{1
95-
inoremap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
96-
snoremap <buffer> <silent> <Tab> <C-o>:<C-u>call xolox#notes#indent_list(1, line("'<"), line("'>"))<CR><C-o>gv
97-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <Tab>"'
98-
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <Tab>"'
99-
inoremap <buffer> <silent> <S-Tab> <C-o>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
100-
snoremap <buffer> <silent> <S-Tab> <C-o>:<C-u>call xolox#notes#indent_list(-1, line("'<"), line("'>"))<CR><C-o>gv
101-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <S-Tab>"'
102-
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <S-Tab>"'
103-
104-
" Indent list items using <Alt-Left> and <Alt-Right>. {{{1
105-
inoremap <buffer> <silent> <A-Right> <C-o>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
106-
snoremap <buffer> <silent> <A-Right> <C-o>:<C-u>call xolox#notes#indent_list(1, line("'<"), line("'>"))<CR><C-o>gv
107-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <A-Right>"'
108-
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Right>"'
109-
inoremap <buffer> <silent> <A-Left> <C-o>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
110-
snoremap <buffer> <silent> <A-Left> <C-o>:<C-u>call xolox#notes#indent_list(-1, line("'<"), line("'>"))<CR><C-o>gv
111-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <A-Left>"'
112-
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Left>"'
94+
" Indent list items using <Tab> and <Shift-Tab>? {{{1
95+
if g:notes_tab_indents
96+
inoremap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
97+
snoremap <buffer> <silent> <Tab> <C-o>:<C-u>call xolox#notes#indent_list(1, line("'<"), line("'>"))<CR><C-o>gv
98+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <Tab>"'
99+
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <Tab>"'
100+
inoremap <buffer> <silent> <S-Tab> <C-o>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
101+
snoremap <buffer> <silent> <S-Tab> <C-o>:<C-u>call xolox#notes#indent_list(-1, line("'<"), line("'>"))<CR><C-o>gv
102+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <S-Tab>"'
103+
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <S-Tab>"'
104+
endif
105+
106+
" Indent list items using <Alt-Left> and <Alt-Right>? {{{1
107+
if g:notes_alt_indents
108+
inoremap <buffer> <silent> <A-Right> <C-o>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
109+
snoremap <buffer> <silent> <A-Right> <C-o>:<C-u>call xolox#notes#indent_list(1, line("'<"), line("'>"))<CR><C-o>gv
110+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <A-Right>"'
111+
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Right>"'
112+
inoremap <buffer> <silent> <A-Left> <C-o>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
113+
snoremap <buffer> <silent> <A-Left> <C-o>:<C-u>call xolox#notes#indent_list(-1, line("'<"), line("'>"))<CR><C-o>gv
114+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <A-Left>"'
115+
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Left>"'
116+
endif
113117

114118
" Automatically remove empty list items on Enter. {{{1
115119
inoremap <buffer> <silent> <expr> <CR> xolox#notes#cleanup_list()

0 commit comments

Comments
 (0)