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#.
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#.
Here is a cleaner and simple way to get the desired output in 3 steps:
1. First click dd in normal mode to delete the first line :
tabControl.PropertyChanged += (s, e) =>
As a result the line below will be moved up where the cursor is placed
{
Notice that the cursor must be placed in the opening { so you can use the %
command as you will see in the 2 step
2. Type Shift+v % (for selection) so you can be sure that the exact block {} will be selected
{
...
};
Note: it is V
(Uppercase) not v
there is a difference between the two commands
v Start Visual mode per character.
V Start Visual mode linewise.
3. Type then d : to delete the selected block
so the sequence will be dd Shift+v %d
you can also check the help to see what %
really do by typing in the command line
:help %
% : Find the next item in this line after or under the cursor and jump to its match. |inclusive| motion. Items can be: ([{}]) parenthesis or (curly/square) brackets
I tried to underline some useful commands but if you understand exactly what the V
and %
do you can select directly the whole block you would like to delete or to modify
The fastest way is probably Vj%d
, but see below for shorter options that work in many cases.
V
= enter Visual line mode.j
= go down one character.%
= go to matching brace.d
= delete the selection.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 };
.