Vim - Join multiple lines
Vim Join multiple line
Sometime, I have to do a task like that: Rewrite this code into a single line:
article_ids = [
1,
2,
3,
4,
....
99,
100
]
For combining multiple lines into a single line efficiently in Vim, especially with a list as long as 1000 items, you might find the usual method of pressing Shift + j
repeatedly quite tedious.
TIL that there is a more efficient way to join a large number of lines is using the command :1,100j
. Tada, just 1s =))
If you want to join all lines in the file, just use: :%j
. This command joins all lines in the file into a single line instantly, making the process much faster.