News for hackers. Stuff that matters.
Re:My Favorite Vim Oneliners for Text Manipulation by MrVandemar on Saturday August 05, 2023 @08:47PM (#37017800)
Here's my favourite:

   vi"
If your cursor is within two quotes on a line, it will select everything inside those quotes to (c)hange, (y)ank or (d)elete or whatever you want. Great if you're the sort of person who writes HTML by hand all the time.
Re:My Favorite Vim Oneliners for Text Manipulation by umanwizard on Saturday August 05, 2023 @09:02PM (#37017897)
You can also use yi" to yank it immediately without selecting it first (replace y with c or d to change or delete, respectively). Replace i with a to include the quotes ("around" rather than "inside"). Replace " with ( [ or { to match other kinds of bracketing characters. And include a number to go more than one set out.

E.g.

    y2a(
means yank everything inside (and including) the second nested pair of parentheses out from the current point.
Re:My Favorite Vim Oneliners for Text Manipulation by williamdclt on Sunday August 06, 2023 @06:06AM (#37020533)
Tbh I hate that vim keeps wanting to make me count. I don’t know if it is the first, second or third nested pair of parentheses, and the time for me to count is probably similar than the time to just select with the mouse. I struggle to believe anybody actually counts when using vim , whether it’s levels of nesting or number of lines.

I wish vim was better at showing what you’re going to operate on, and edit it before the operation. Eg a( could select out of the first parentheses then n to extend until everything I want selected is, then y

Re:My Favorite Vim Oneliners for Text Manipulation by umanwizard on Sunday August 06, 2023 @10:57AM (#37022649)
You might like Kakoune, which basically works how you describe.
Re:My Favorite Vim Oneliners for Text Manipulation by KRAKRISMOTT on Saturday August 05, 2023 @08:58PM (#37017877)
The v is redundant unless you want highlighting. You can do yi" directly (or ci" or di").

For more fun, activate vim-surround. E.g. to replace surrounding quotes with parentheses: cs"(

Re:My Favorite Vim Oneliners for Text Manipulation by riffraff on Sunday August 06, 2023 @02:38AM (#37019527)
it's fun, I have had vim-surround installed for years but keep forgetting how that it exists.
Re:My Favorite Vim Oneliners for Text Manipulation by TonyStr on Sunday August 06, 2023 @02:43AM (#37019550)
vi"p or vi"P is a great way to overwrite "" contents with the contents of your unnamed register
Re:My Favorite Vim Oneliners for Text Manipulation by Izkata on Sunday August 06, 2023 @02:47AM (#37019568)
I habitually use visual mode for a lot of stuff like that so quick flash shows me what was affected (in case of typo). If the highlighted part isn't what I expected I instantly know to undo, rather than having to think about the resulting text for a moment.
Re:My Favorite Vim Oneliners for Text Manipulation by williamdclt on Sunday August 06, 2023 @06:02AM (#37020513)
Same. Which shows a weakness of vim, I think it’d be much more usable if it had the verb last: iw would select the word then you can delete, yank, or even extend the selection knowing exactly what you’re going to operate on.

I think kakoune works like that, but I don’t have the will to learn another editor and vi is what’s available everywhere anyway

Re:My Favorite Vim Oneliners for Text Manipulation by xigoi on Sunday August 06, 2023 @11:30AM (#37022994)
The problem with Kakoune-like object-action order is that you need more modifier keys.
Re:My Favorite Vim Oneliners for Text Manipulation by qrio2 on Monday August 07, 2023 @12:48PM (#37037020)
surround and sneak are my desert island vim plugins
Re:My Favorite Vim Oneliners for Text Manipulation by evanrich on Saturday August 05, 2023 @10:40PM (#37018460)
Doesn’t have to be within, will visually select the contents of the first quotes on the line!