简体   繁体   中英

How to join multiple lines into one line with VS Code?

In Sublime Text 3, having multiple cursors on several lines and joining them with CMD+J results in a single line:

在此处输入图片说明

However, the same operation in VS Code (CTRL+J), results in half the number of initial lines (in this case 3 / 2 = 1.5 ≈ 2):

在此处输入图片说明

Is there a way to join all lines into one line in VS Code?

There is a command editor.action.joinLines which doesn't have a default keybinding. When you trigger it, you get the result you want.

{
  "key": "ctrl+alt+j",  // or your keybinding
  "command": "editor.action.joinLines"
}

No need for a cursor on the multiple lines, just select the lines you want to join and trigger the command (either with some keybinding or in the Command Palette).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM