Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings to change nerd leader key #433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ Please see the vim help system for full documentation of all options: `:help ner
Several settings can be added to your vimrc to change the default behavior. Some examples:

```vim
" Change nerdcommenter leader key. default is 'c'
let g:NERDLeaderKey = 'v' " v is for the example, you can set anything

" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1

Expand Down
32 changes: 19 additions & 13 deletions plugin/NERD_commenter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3168,21 +3168,27 @@ function! s:CreateMaps(modes, target, desc, combo)
endif
endfor
endfunction
call s:CreateMaps('nx', 'Comment', 'Comment', 'cc')
call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c<space>')
call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm')
call s:CreateMaps('nx', 'Nested', 'Nested', 'cn')
call s:CreateMaps('n', 'ToEOL', 'To EOL', 'c$')
call s:CreateMaps('nx', 'Invert', 'Invert', 'ci')
call s:CreateMaps('nx', 'Sexy', 'Sexy', 'cs')
call s:CreateMaps('nx', 'Yank', 'Yank then comment', 'cy')
call s:CreateMaps('n', 'Append', 'Append', 'cA')

" check if custom NERDLeaderKey is used, and set it to 'c' if not set
if !exists('g:NERDLeaderKey') || type('g:NERDLeaderKey') != 1
let g:NERDLeaderKey = 'c'
endif

call s:CreateMaps('nx', 'Comment', 'Comment', g:NERDLeaderKey . 'c')
call s:CreateMaps('nx', 'Toggle', 'Toggle', g:NERDLeaderKey . '<space>')
call s:CreateMaps('nx', 'Minimal', 'Minimal', g:NERDLeaderKey . 'm')
call s:CreateMaps('nx', 'Nested', 'Nested', g:NERDLeaderKey . 'n')
call s:CreateMaps('n', 'ToEOL', 'To EOL', g:NERDLeaderKey . '$')
call s:CreateMaps('nx', 'Invert', 'Invert', g:NERDLeaderKey . 'i')
call s:CreateMaps('nx', 'Sexy', 'Sexy', g:NERDLeaderKey . 's')
call s:CreateMaps('nx', 'Yank', 'Yank then comment', g:NERDLeaderKey . 'y')
call s:CreateMaps('n', 'Append', 'Append', g:NERDLeaderKey . 'A')
call s:CreateMaps('', ':', '-Sep-', '')
call s:CreateMaps('nx', 'AlignLeft', 'Left aligned', 'cl')
call s:CreateMaps('nx', 'AlignBoth', 'Left and right aligned', 'cb')
call s:CreateMaps('nx', 'AlignLeft', 'Left aligned', g:NERDLeaderKey . 'l')
call s:CreateMaps('nx', 'AlignBoth', 'Left and right aligned', g:NERDLeaderKey . 'b')
call s:CreateMaps('', ':', '-Sep2-', '')
call s:CreateMaps('nx', 'Uncomment', 'Uncomment', 'cu')
call s:CreateMaps('n', 'AltDelims', 'Switch Delimiters', 'ca')
call s:CreateMaps('nx', 'Uncomment', 'Uncomment', g:NERDLeaderKey . 'u')
call s:CreateMaps('n', 'AltDelims', 'Switch Delimiters', g:NERDLeaderKey . 'a')
call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '')
call s:CreateMaps('', ':', '-Sep3-', '')
call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '')
Expand Down