Ctrl+enter in sublimetext is a default shortcut to create a new line, no matter in what position your cursor are in the current line. However, sometimes I need to add a semicolon at the end of the current line before jump to a new line.
How can i make the "ctrl+enter" shortcut add a semicolon to the end of the current line before create a new line? Is it even possible?
sorry for my english.
You can simply modify the macro /Default/Add Line.sublime-macro
to insert the semicolon.
From this
[
{"command": "move_to", "args": {"to": "hardeol"}},
{"command": "insert", "args": {"characters": "\n"}}
]
to this
[
{"command": "move_to", "args": {"to": "hardeol"}},
{"command": "insert", "args": {"characters": ";\n"}}
]
After AGS's answer, I solved my problem with similar approach. You can do this:
1. Create a macro file in the folder ~/.config/sublime-text-3/Packages/User
with:
[
{
"args":
{
"to": "hardeol"
},
"command": "move_to"
},
{
"args":
{
"characters": ";"
},
"command": "insert"
},
{
"args":
{
"characters": "\n"
},
"command": "insert"
}
]
2. Then edit your keybindings Preferences > Key Bindings - User
. Add this:
{ "keys": ["ctrl+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/User/FILENAME.sublime-macro"} },