Duplicate the line and comment on the old

I often need to edit a line, but comment on it.

Is it possible to create a key binding for these commands in Sublime Text 2?

  • duplicate current row
  • comment the top line
  • move the cursor to the bottom line
0
source share
1 answer

Assuming the comment syntax is specific to the file type, you can use a simple macro (although even if you don't, the macro will be a bit more active). In any case, save the following Packages/Useras you like. Make sure the extension .sublime-macro.

[
    {
        "args":
        {
            "block": false
        },
        "command": "toggle_comment"
    },
    {
        "command": "duplicate_line"
    },
    {
        "args":
        {
            "block": false
        },
        "command": "toggle_comment"
    }
]

Then create a key binding as shown below.

{ "keys": ["f12"], "command": "run_macro_file", "args": {"file": "res://Packages/User/<the file name>.sublime-macro"} },

, keys <the file name> .

+2

Source: https://habr.com/ru/post/1651554/


All Articles