Skip to content

Commit

Permalink
Add a string that marks inserted comments (tpope#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelya committed Nov 23, 2020
1 parent 25a8f59 commit 3ce1eea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions doc/commentary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ 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();
The |User| CommentaryPost autocommand fires after a successful operation and
can be used for advanced customization.

Expand Down
8 changes: 7 additions & 1 deletion plugin/commentary.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ if exists("g:loaded_commentary") || v:version < 700
endif
let g:loaded_commentary = 1

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

function! commentary#surroundings() abort
" Ensure whitespace around %s and postfix comment leader with ~ to make auto
" commented code easier to find.
return split(get(b:, 'commentary_format', substitute(substitute(substitute(
\ &commentstring, '^$', '%s', ''), '\S\zs%s',' %s', '') ,'%s\ze\S', '%s ', '')), '%s', 1)
\ &commentstring, '^$', '%s', ''), '\S\zs%s', g:commentary_marker.' %s', '') ,'%s\ze\S', '%s ', '')), '%s', 1)
endfunction

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

0 comments on commit 3ce1eea

Please sign in to comment.