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

Add a string that marks inserted comments #87

Open
wants to merge 1 commit 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
15 changes: 15 additions & 0 deletions doc/commentary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ 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") || &cp || v:version < 700
endif
let g:loaded_commentary = 1

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

function! s: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(
\ &commentstring, '\S\zs%s',' %s','') ,'%s\ze\S', '%s ', '')), '%s', 1)
\ &commentstring, '\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