vim-textobj-user icon indicating copy to clipboard operation
vim-textobj-user copied to clipboard

Matching a single newline results in unexpected behaviour

Open AlexanderHarrison opened this issue 2 years ago • 0 comments

call textobj#user#plugin('newline', {
\   '-': {  
\     'pattern': '\n',
\     'select': 'n',
\   },
\ })

Instead of matching a single newline like expected, this matches from the previous newline to the following newline. This persists even with the 'cursor' scan type. It seems to work when the cursor is somehow on the newline character (such as on blank lines).

This issue is specific to newlines. Changing the matched character to something else matches the single character like expected.

This arose when I was trying to match whitespace with:

call textobj#user#plugin('space', {
\   '-': {  
\     'pattern': '\S\zs\_s\+',
\     'select': 's',
\   },
\ })

Which works as expected for every case except for single newlines.

AlexanderHarrison avatar Aug 12 '21 18:08 AlexanderHarrison