How do I join two lines in vi?

Vijay picture Vijay · Dec 16, 2009 · Viewed 131.6k times · Source

I have two lines in a text file like below:

S<Switch_ID>_F<File type>
_ID<ID number>_T<date+time>_O<Original File name>.DAT

I want to append the two lines in vi like below:

S<Switch_ID>_F<File type>_ID<ID number>_T<date+time>_O<Original File name>.DAT

The second line got deleted and the contents of the second line was appended to the first line.

How could I do it using command mode in vi?

Answer

GJ. picture GJ. · Dec 16, 2009

Shift+J removes the line change character from the current line, so by pressing "J" at any place in the line you can combine the current line and the next line in the way you want.