In Vim, one can join two lines by typing capital J. However, these are usually joined by a space.
I seem to remember there was a way to change the character used for the joining by setting some variable, but I can't seem to find it again.
I'd appreciate it if anyone could remind me, or confirm that it can't be done.
Once in insert mode, typing inserts characters just like a regular text editor. You can enter it by using an insert command from normal mode. Insert commands include: i for 'insert', this immediately switches vim to insert mode.
You can type f<character> to put the cursor on the next character and F<character> for the previous one. You can also use ; to repeat the operation and use , to repeat it in opposite direction.
The f command is very similar to the t command, but it places your cursor on top of the character. The F command works how you might expect, moving your cursor backwards and on top of the next occurrence of the selected character.
When I want to join just a few lines I use a 3 keys combo (normal mode):
Jr,
being ,
the joining character.
In case I want to join more lines or even join lines in groups, I use the previous combo with a macro.
For example, to transform 3 lines in a 3 columns CSV table, I record this macro (assigned to letter j
of course):
qjJr,Jr,jq
So, using @j
joins 3 lines using ,
and goes to the next line.
10@j
converts 10 lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With