Nelu
Nelu

Reputation: 18710

Duplicate line and comment out old one

I often need to edit a line but comment out the old one.

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

Upvotes: 0

Views: 113

Answers (1)

skuroda
skuroda

Reputation: 19744

Assuming the comment syntax is defined for the file type, you can use a simple macro (though even if it's not you could do it, the macro would just be a little more involved). Anyways, save the following in Packages/User as whatever you like. Be sure the extension is .sublime-macro though.

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

Then, create a key binding like the following.

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

Of course, change the keys and <the file name> as appropriate.

Upvotes: 2

Related Questions