8000 inconsistency in selecting empty line followed by closing bun at the start of line · Issue #161 · machakann/vim-sandwich · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

inconsistency in selecting empty line followed by closing bun at the start of line #161

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

Open
tomtomjhj opened this issue Jun 6, 2023 · 0 comments

Comments

@tomtomjhj
Copy link
Contributor

Hi, I want to select the lines surrounded by a pair of comment markers like this:

/*
line 1
line 2
*/

So I tried the following recipes, but they don't work properly for empty lines.
Run with vim --clean -u repro.vim, and use ic and iC mappings to select the lines.

" repro.vim
set nocompatible

set rtp^=~/.vim/plugged/vim-sandwich
let g:sandwich#recipes = [
      \   {'buns': ['\v^/\*\n', '\v\n\*/$'], 'regex': 1, 'kind': ['textobj'], 'input': ['c']},
      \   {'buns': ['\v^/\*\n', '\v^\*/$'],  'regex': 1, 'kind': ['textobj'], 'input': ['C']},
      \ ]

xmap ic <Plug>(textobj-sandwich-query-i)c
xmap iC <Plug>(textobj-sandwich-query-i)C

insert
/*
But if the last line is empty,
`ic` doesn't include the last line, and
`iC` includes the comment marker

*/
.

ic:
image

iC:
image

Is it possible to make a recipe that properly selects the entire lines surrounded by the markers, like this?
image

@tomtomjhj tomtomjhj changed the title empty line, EOL, and closing bun empty line followed by closing bun at the start of line Jun 6, 2023
@tomtomjhj tomtomjhj changed the title empty line followed by closing bun at the start of line inconsistency in selecting empty line followed by closing bun at the start of line Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0