vimvsvim

vim delete lambda variable and block


I have cursor at first t and I want to delete all this code from t to };\n without lines counting.

How can I achieve it? Is there cleaner way than d/};$/e?

tabControl.PropertyChanged += (s, e) =>
{
    ...
};

If it matters, this is C#.


Solution

  • The fastest way is probably Vj%d, but see below for shorter options that work in many cases.

    Alternatively, if there are no empty lines in the lambda, but there is an empty line after it, I would use d} (} is go to 'end of paragraph', which usually means the next empty line) or dap (neumonic: 'delete all paragraph', works from anywhere in the 'paragraph', assuming your function has empty lines before and after). dap is really useful for deleting short blocks of code.

    Note also that your solution will not work if there is a nested lambda terminated by };.