glts / vim-textobj-comment

Vim text objects for comments
http://www.vim.org/scripts/script.php?script_id=4570
130 stars 8 forks source link

Add option to split multiline comments on fold markers #4

Closed somini closed 7 years ago

somini commented 8 years ago

How hard would be to add an option to stop the multiline comment detection on fold markers?

What I mean is this, || means the cursor location:

"}}}
" Appearance {{{
" hi link EasyMotionShade         Comment
" hi link EasyMotionTarget        IncSearch ||
" hi link EasyMotionTarget2First  MatchParen
" hi link EasyMotionTarget2Second MatchParen
"}}}
"}}}
" Visualstar {{{

This is technically a single multi-line comment, but logically (IMHO), if you run vac it should select only this:

" hi link EasyMotionShade         Comment
" hi link EasyMotionTarget        IncSearch
" hi link EasyMotionTarget2First  MatchParen
" hi link EasyMotionTarget2Second MatchParen

I understand this requirement shouldn't be the default, but there should be an option to toggle this behaviour. I can submit a PR for this, just need a pointer for where to start.

glts commented 8 years ago

I'm reluctant to add anything language-specific to this plugin. Fold markers are a Vim thing and I'm not sure they naturally integrate with comments or should be coupled to comment syntax.

I can imagine that people might want other 'embedded' constructs to somehow influence what part of a comment is selected. For example the block tags section in a Javadoc comment (lines at the bottom of the doc comment starting with an @ block tag), or simply comment 'paragraphs' in general (blank commented line separates paragraphs).

In this particular case, I wonder if you might not be better served by a fold text object? viz to select the fold contents under the cursor?

somini commented 8 years ago

Yeah, that wasn't a good example. A better example would have other non-comments in the fold. I do have a fold text object. ☺ My use case is having several folds together, without newlines between them, with a multi-line header on top of each.

glts commented 7 years ago

Re-reading my earlier comment I find myself still agreeing with it, closing.