Skip to content
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
16 changes: 16 additions & 0 deletions doc/commentary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ gcu
*:Commentary*
:[range]Commentary Comment or uncomment [range] lines


*g:commentary_marker*
g:commentary_marker A string that marks comments inserted by commentary.
This marker is inserted immediately after the comment
string. Useful if commentary is only used to disable
code (rather than inserting explanatory comments).

For example, >
let g:commentary_marker = '~'
< will comment >
f();
< into >
//~ f();
<
Use |b:commentary_marker| for a buffer-local override.

The |User| CommentaryPost autocommand fires after a successful operation and
can be used for advanced customization.

Expand Down
14 changes: 12 additions & 2 deletions plugin/commentary.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ if exists("g:loaded_commentary") || v:version < 703
endif
let g:loaded_commentary = 1

if !exists("g:commentary_marker")
let g:commentary_marker = ''
endif

function! s:surroundings() abort
return split(get(b:, 'commentary_format', substitute(substitute(substitute(
\ &commentstring, '^$', '%s', ''), '\S\zs%s',' %s', '') ,'%s\ze\S', '%s ', '')), '%s', 1)
" Get commentstring with %s and whitespace padding.
let cms = substitute(substitute(substitute(
\ &commentstring, '^$', '%s', ''), '\S\zs%s',' %s', '') ,'%s\ze\S', '%s ', '')
" Postfix comment leader with marker to make auto commented code easier to find.
let marker = get(b:, 'commentary_marker', g:commentary_marker)
let cms = substitute(cms, '\S\zs\s*%s', marker ..'&','')
let fmt = get(b:, 'commentary_format', cms)
return split(fmt, '%s', 1)
endfunction

function! s:strip_white_space(l,r,line) abort
Expand Down