Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the join character in Vim?

Tags:

vim

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.

like image 890
merlin2011 Avatar asked Mar 26 '12 18:03

merlin2011


People also ask

How do I insert a character in Vim?

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.

How do I go to a specific character in Vim?

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.

What does F do in Vim?

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.


1 Answers

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.

like image 185
migonzalvar Avatar answered Sep 28 '22 06:09

migonzalvar