Create Word Wrap shortcut key in Sublime Text

Sublime Text is a sophisticated text editor developed by Jon Skinner features Python API. Sublime Text provides variety of default shortcuts like for font size, managing file etc. which facilitates developers to change settings easily.

Sometimes you need to create custom shortcut for required features. For example, You need to turn on word wrap to see or copy all the text of line and need to turn off word wrap to view or adjust indentation. While you can turn word wrap on or off from Tools > Word Wrap menu. But when you want to turn Word Wrap on or off many times, it becomes headache to turn Word Wrap on off from menu.

For that, you can create custom shortcut to turn Word wrap on off easily. Here is how you can do it.

First go to the menu Preferences > Key Bindings.

This will open new Sublime Text window with two files open:

On the left side file, all default Sublime Text shortcut key settings and right side custom shortcut settings.

On the right side file, add the below json code into brackets[].

{
    "keys": ["ctrl+shift+c"],
    "command": "toggle_setting",
    "args": {
        "setting": "word_wrap"
    }
}

Now press CTRL + S to save the file. The file should looks like this.

Now open any file with long line to check the settings. Below file is when Word Wrap is on.

Now press CTRL+SHIFT+C shortcut and the Word Wrap will turn off.

That way, you can also create custom shortcuts for any features. It also works for Sublime Text 3. I hope it will help you.

Tags: