Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard shortcut to do the opposite of ENTER in VSCode (unindent and remove line feed)?

Tags:

If I move the cursor to somewhere in the middle of a line of code, and I press the ENTER key, the text on the right is moved to the next line and it gets automatically indented.

But sometimes I want to do the opposite, to join two lines, but without the indentation of the second line. So, first I need to move the cursor to the beginning of the second line, just after the indentation, then erase all the spaces/tabs until I reach the first line.

Is there any keyboard shortcut or extension to achieve this?

like image 959
kiewic Avatar asked Mar 03 '18 03:03

kiewic


1 Answers

Yes, there is. It's name is "Join Lines". To use it simply put the cursor on the above line, then press ctrl+shift+p (or click View -> Command Palette) and write "join" and select Join Lines command from the options:

enter image description here

If you like a keyboard shorcut to this command press again ctrl+shift+p and write "open", then select Preferences: Open Keyboard Shortcuts, search for Join Lines and add your desired key combination:

enter image description here

Hope it's useful for you.

like image 75
4ndt3s Avatar answered Sep 22 '22 13:09

4ndt3s