Sublime Forum

Join lines without space (gJ in vim)

#1

Is this possible to implement this feature as a key mapping? In vim, if you type the command “gJ”, it’ll join the following line with the current one but without adding a space in between. It’s similar to the J command but without the space.

1 Like

#2

Think the following macro could do what you want.

	{
		"command": "move_to",
		"args":{"to": "eol", "extend": false}
	},
	{
		"command": "join_lines"
	},
	{
		"command": "left_delete"
	}
]

Save it as “<some_name>.sublime-macro” in Packages/User. Then for the key binding use something like the following

"keys": "f10"], "command": "run_macro_file", "args": {"file": "res://Packages/User/macros/Join Without Space.sublime-macro"} ]

Of course, adjust the name and keys as you need to. In fact, you could probably use “context”: {“key”: “setting.command_mode”, “operand”: true} for the context and “g”, “shift+j”] for the keys to follow the same binding in ST (assuming you have vintage enabled).

1 Like

#3

Thanks for the help!
I modified mine to work for multiple lines.

[
   {
      "args": null,
      "command": "split_selection_into_lines"
   },
   {
      "command": "move_to",
      "args":{"to": "eol", "extend": false}
   },
   {
      "command": "join_lines"
   },
   {
      "command": "left_delete"
   }
]
0 Likes