Quite a common task in programming is to remove the condition on the current block.
In vim, is there an easy way to delete the first line (the ‘if’ statement) and last line (the closing curly brace) of the current block and perhaps reindent accordingly. If there is no simple key combination for this built in, what is a straightforward way to script it?
Thinking about this a bit further, of course the condition on the if statement may span multiple lines so presumably a script is required to capture this completely. However, for my code just deleting the first and last lines would capture 95% of cases.
Possible solution
yiByanks the inner blockvaBVviaually select a block, then select it linewiseppaste over visually selected textgv<reselect text and de-indentSurround like mappings aka delete surrounding block:
ib provided a shorter solution. This solution will not mutate the visual marks:
'<,'>diBdeletes the current inner block]ppaste the newly deleted text below the end of the block but adjust the indent.kdkmove up a line and then delete 2 lines up thereby deleting the start and end of the block.