Fork me on GitHub
#vim
<
2024-06-01
>
practicalli-johnny16:06:10

Vim editing magic question. How can I delete a variable amount of space between the two columns of text and repeat that for a very long list, e.g in dot-repeat or macro. Assume all text in the second column starts with different characters or numbers), A small example

DeLaGuardo/setup-clojure        12.5        
actions/cache                   v4.0.2      
clj-kondo/clj-kondo             2024.05.24
I am aware I can use E to jump to the last character of the first column, but then what command can I use to remove all the whitespace up to the next column (except 1 whitespace preferably - although I can use l to move before deleting the whitespace). I suspect the answer will be substitution & regex...

Noah Bogart16:06:54

if you're on the first space after the symbol, something like cw<space> should delete all of the whitespace until the next word and enter Insert mode and then insert a space.

practicalli-johnny16:06:44

I had tried dw and it didnt work, but maybe I had pressed something else before. Now I try again it works (which I thought it should)... no idea why it didnt work before. cw<space> is nice. Thanks.

👍 1
brwong16:06:35

I normally just use a visual block selection in a situation like this definitely curious if someone else has a better (or less "interactive") solution

👍 1
Jan K17:06:51

I suspect the answer will be substitution & regex...Can do :s/ \+/ / (fixed as Noah suggested)

Noah Bogart17:06:52

lol make sure it's +, so it matches at least one

emilaasa06:06:14

Not the cleanest way perhaps, but I'd do something like this: