vim

practicalli-johnny 2024-06-01T16:31:10.363709Z

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...

2024-06-01T16:35:54.388709Z

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-johnny 2024-06-01T16:42:44.243389Z

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
brwong 2024-06-01T16:53:35.264179Z

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 K 2024-06-01T17:20:51.033229Z

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

2024-06-01T17:38:52.855979Z

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

emilaasa 2024-06-03T06:45:14.884049Z

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

emilaasa 2024-06-03T06:57:30.349529Z

I also used https://github.com/junegunn/vim-easy-align in the past