Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcut for joining two lines

What's the keyboard shortcut for joining two lines in VS Code?

If the cursor is anywhere in the first line of

    f(foo,       bar) 

then when I hit the shortcut, I want to get

    f(foo, bar) 
like image 228
Jo Liss Avatar asked Sep 29 '17 14:09

Jo Liss


People also ask

How do I join lines in vi?

When you want to merge two lines into one, position the cursor anywhere on the first line, and press J to join the two lines. J joins the line the cursor is on with the line below. Repeat the last command ( J ) with the . to join the next line with the current line.

Which command joins next line to current line?

Joins consecutive lines. The J (join) command joins a specified number of lines together as one line. Number of consecutive lines, starting with the current line, to be joined to the current line.

How do you repeat code in VS code?

“how to repeat lines in vscode *” Code Answer On Windows: Shift + Alt + Up/Down. On Mac: Shift + Option + Up/Down. On Ubuntu: Ctrl + Shift + Alt + Up/Down.


2 Answers

Visual Studio Code now comes with a default key binding for joining lines, Ctrl + J.

You can find all keyboard shortcuts under Preferences > Open Keyboard Shortcuts.

You can overwrite it using the UI or by providing a different key combination for the command editor.action.joinLines in keybindings.json.

like image 92
Marlon Bernardes Avatar answered Oct 12 '22 13:10

Marlon Bernardes


Press F1, and type Join Lines. By default there is no key bindings to it yet, but you can easily set it under 'Preferences > Keyboard Shortcuts', then search for Join Lines and set a shortcut.

like image 41
mlwh Avatar answered Oct 12 '22 13:10

mlwh