News for hackers. Stuff that matters.
Re:Leap: Neovim’s Answer to the Mouse by Izkata on Saturday October 08, 2022 @05:29PM (#33136190)
Others have mentioned relativenumber, but for horizontal I just use search. For example:

   This is a line of text.
If the cursor is on "is" and you want to delete everything before "text", this is what I do:

   d/text<enter>
Any movement works for these actions, even searching to "select" everything between the cursor and the target. Often I'll use visual mode to get a quick confirmation before deleting it:

   v/text<enter>h
   (check selection is what I want)
   d
The visual mode one isn't exactly the same because one additional character, the first "t" in "text", is in the visual selection area, hence the "h" to go back one.
Re:Leap: Neovim’s Answer to the Mouse by minusf on Saturday October 08, 2022 @06:12PM (#33136532)
> d/text<enter>

if you have a unique letter, as in this case ("t"), a quicker way is "dtt" (delete till "t") or "ctt" (change till "t"). in case of non unique character it takes a count but that scales badly for me, and i use /.

Re:Leap: Neovim’s Answer to the Mouse by cassepipe on Saturday October 08, 2022 @06:22PM (#33136593)
I have to personally thank you for that one. Thank you.
Re:Leap: Neovim’s Answer to the Mouse by oktwtf on Saturday October 08, 2022 @06:47PM (#33136777)
These discussions are always a gold mine of tips.!

Also I like to use "f" for find followed by the character you wish to move cursor to the character you desire to end up on the present line. (ex. "fl" jumps to the first "l" of the line.)

Re:Leap: Neovim’s Answer to the Mouse by amelius on Saturday October 08, 2022 @08:03PM (#33137183)
And you can also type d2ft to delete everything up to and including the second t, for example.

(I personally think of "f" as "find", not "first")

Re:Leap: Neovim’s Answer to the Mouse by oktwtf on Saturday October 08, 2022 @09:24PM (#33137525)
I never even thought to numerically increment the action!

What beautiful chords at this here fireside chat.

Re:Leap: Neovim’s Answer to the Mouse by zefhous on Sunday October 09, 2022 @12:01AM (#33138177)
There’s also the `;`, which repeats the last movement! So if you did `dft` and didn’t see the extra “t” in the way in the first place, you can then just do `d;`. It’s like `.` but for movement!

I think that’s right anyway, no vim terminal at hand to check myself.

Re:Leap: Neovim’s Answer to the Mouse by cuddlecake on Sunday October 09, 2022 @04:20AM (#33139075)
Wouldn't just `.` do the same as `d;` in that case?
Re:Leap: Neovim’s Answer to the Mouse by amelius on Sunday October 09, 2022 @11:38AM (#33142235)
Not always, the ";" sets the repetition-count of the operation to 1.

You can type "d2;" however.

Re:Leap: Neovim’s Answer to the Mouse by cuddlecake on Sunday October 09, 2022 @03:02PM (#33144192)
Good to know, thank you
Re:Leap: Neovim’s Answer to the Mouse by oktwtf on Sunday October 09, 2022 @03:18PM (#33144322)
Oh great, I’ll finally have to remove my remap of ‘; = :’ never did I investigate to know what I was opting out of.
Re:Leap: Neovim’s Answer to the Mouse by paledot on Tuesday October 11, 2022 @09:41PM (#33171706)
Not worth it. That remap has saved me more keystrokes than I can reasonably count. But adding the opposite remap for good measure isn't the worst idea.
Re:Leap: Neovim’s Answer to the Mouse by nyx on Saturday October 08, 2022 @10:00PM (#33137700)
I think of the t motion as "to", and the f motion as "frough" (rhymes with through: "delete frough the second t").
Re:Leap: Neovim’s Answer to the Mouse by bch on Saturday October 08, 2022 @10:37PM (#33137835)
Beautiful - the ways I’ve never considered composing…
Re:Leap: Neovim’s Answer to the Mouse by wyager on Saturday October 08, 2022 @07:23PM (#33136990)
How does dtt differ from dft?
Re:Leap: Neovim’s Answer to the Mouse by aGHz on Saturday October 08, 2022 @07:27PM (#33137015)
dtt will stop just before the first t character, dft will delete the t as well.
Re:Leap: Neovim’s Answer to the Mouse by kevincox on Saturday October 08, 2022 @11:20PM (#33137998)
In the case of dtt you can also often repeat it with . if you have a "false positive" before the intended character rather than counting occurances. Not for c but for d if you don't need the yanked text and regular movement.
Re:Leap: Neovim’s Answer to the Mouse by u801e on Saturday October 08, 2022 @07:29PM (#33137019)
Another approach is to use normal mode to delete a block of text you want. For instance, if you want to delete up to the line before the line that contains "This is a line of text", you could run

    q:
    .,/This is a line of text/- d
. is the current line. /This is a line of text/ is the line that contains it and the - after the regex refers to the line immediately above. You could use _ to refer to the line immediately after, or -x or +x where x refers to the number of lines above or below the line that the regex matched.
Re:Leap: Neovim’s Answer to the Mouse by koprulusector on Saturday October 08, 2022 @11:06PM (#33137942)
Never knew about the - or _ as flags for the search regex. This is awesome!
Re:Leap: Neovim’s Answer to the Mouse by u801e on Sunday October 09, 2022 @12:32AM (#33138287)
It's not actually a flag to the s command. It's a way to modify the address. So, for instance, if you want to delete from the third line to the third to last line in the file, you could run:

    :1+2,$-2 d
1 is the address of the first line in the file and $ is the address of the last line in the file. Add 2 to the first to get the third line and subtract 2 from the last to get the third to last line. The d command deletes the lines in the address range.

You can also address lines with a regex, like I did in the example in my previous comment. You can even use regex addressing for ranges. If you wanted to delete a python method definition in between other method definitions, you could do something like:

  :/def method_to_delete/,/def/- d
which would start the range with the line that contains def method_to_delete and delete lines up to the line before the next line that contains the def keyword that starts the next method definition.
Re:Leap: Neovim’s Answer to the Mouse by shepherdjerred on Saturday October 08, 2022 @10:40PM (#33137849)
> d/text<enter>

You've changed my life