Quick Tip: Enable Sublime Text Word Wrap

I’m a big fan of Sublime Text 2 and it has become my default editor for all things web design. However, there was something about the default behavior of this app that really bugged me. Whenever I would browse a document I would always get frustrated by the way the application would horizontally scroll whenever a document had really long lines of code (like lengthy CSS declarations). I knew there had to be a way to force the code to wrap to a new line and disable this behavior. Well, after a long Google search, I found the answer, and thought I’d share with you how to enable Sublime Text word wrap.

Access the User Syntax Settings

Sublime has very extensive customization capabilities. Unfortunately, they’re not stored in a preferences dialog box, they’re accessed via coding. This is a cool feature for more advanced users, but I’d imagine it’s frustrating for most beginners. Here’s how to access the preferences document.

NOTE: These instructions are for Mac users. Windows/Linux operations are the same, but menus will be different.

  • Click Sublime Text 2 > Preferences > Settings – More > Syntax Specific – User

sublimetext1

When you open this file, it will correspond to whatever type of document you currently have open. This means if you’re working on a CSS document, you’ll be editing preferences for all documents that end in .css. I went ahead and opened a .css file first, just to make sure this worked, then I opened up a .html, .php, and .js file to ensure I had matching settings across the board.

Enable Word Wrap Setting

Now it’s time to type out the actual code for the setting that we’re going to enable. Just copy and paste the code below into the preferences document and you’ll be all set.

{
"word_wrap": true
}

Now save your document, close it, and restart Sublime Text 2. Once you do that, open a document that previously had horizontal scrolling problems. Now the code should wrap once it hits the edge of the window and scrolling should be disabled.

Conclusion

There are many other settings that can be customized through the Sublime Text 2 preferences and I highly recommend that you read through the documentation in order to fully understand what it’s capable of. Hopefully this article was helpful. Thanks for reading!

Posted by Justin Seeley

  1. Hey Justin,

    Thanks for the tip! I do have a question however, how does this method differ from View > Word Wrap?

    Reply

    1. This sets word wrapping on a syntax level. Meaning you can turn it on for specific types of docs (HTML, CSS, etc.) vs turning on for all documents. Plus, in my experience, the View>Word Wrap didn’t do what I wanted it to do on a regular basis. This fixed my problem instantly.

      Reply

      1. Gotcha. Thanks for the tip!

        Reply

        1. Thanks for reading, Paolo. Always great to hear from you 🙂

          Reply

  2. have the same prob. you can also set
    “word_wrap”: “auto”,
    to
    “word_wrap”: “true”,
    in Preferences>Settings-Default,
    so you dont have to click view>word wrap everytime. 🙂

    Reply

  3. Works for SublimeText 3, thank you.

    Reply

  4. thank you for sharing.

    Reply

  5. Thanks! This is exactly what I’ve been looking for.

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *