vim-sandwich icon indicating copy to clipboard operation
vim-sandwich copied to clipboard

[Question] How to properly indent a linewise surrounded block?

Open luiz00martins opened this issue 4 years ago • 1 comments

Hi! After searching through the issue tracker for a bit, I've found a way to re-indent the inner block after a linewise surround, with 'command': ["'[,']normal! =="]:

let g:sandwich#recipes += [{'buns': ['for () {', '}'], 'input': ['bf'], 'linewise': 1, 'command': ["'[,']normal! =="]}]

However, this has a problem. If you try to add the cursor option, the command changes the last positioning of the cursor. For example, executing this recipe:

let g:sandwich#recipes += [{'buns': ['for () {', '}'], 'input': ['bf'], 'linewise': 1, 'command': ["'[,']normal! =="], 'cursor': 'head'}]

leaves the cursor at the end of the block, even though 'cursor': 'head' was specified. I imagine this happens because the command changed the cursor position.

Is there a way to indent the inner block, which doesn't break the cursor option?

luiz00martins avatar Dec 10 '21 22:12 luiz00martins

Thank you for your report. This is probably a bug, but I'm not sure there could be a good solution. Anyway, I will try to fix it.

machakann avatar Dec 12 '21 14:12 machakann