Configuring Sublime Text for Markdown
I’ve taken to writing documentation in Markdown as of late. It gives me the flexibility to compile the text into any format I need. I use Sublime Text as my editor for this, but today that brought up a problem.
The Spacing Problem
I was writing up a doc, and noticed that markdown was not recognizing my line breaks. I went over to the documentation, and discovered, as I usually do when going the the Daring Fireball site, a nice tidbit of info:
When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.
Great! I went back into Sublime and added my spaces. All well and good.
Or not.
Sublime text likes to trim any additional unneeded white space upon saving files, which I normally find to be a nice feature. This very feature was stopping me in my tracks, however.
Syntax Specific Settings
In order to fix this, I needed settings for Markdown files only. I didn’t want to lose my precious whitespace trimming in other filetypes. In order to do so, make sure you have a markdown file open and go here:
Preferences > Settings – More > Syntax Specific – User
This should open a file called Markdown.sublime-settings. Add the following code:
{
// Which file extensions go with this file type?
"extensions":
[
"md",
"mdown",
"mdwn",
"mmd",
"txt"
],
// Set to true to removing trailing white space on save
"trim_trailing_white_space_on_save": false
}
Save the file, and that’s that. Now, any trailing whitespace for the above file types will live on.
Comments (8)
Leave a Reply
HI I just found the site by ready the less tip for placeholders!
Link to commentI currently use Coda for my development but I heard good things about sublime. May I ask how do you manage all the ftp sites info? I love coda site manager to store all my client sites but the editor is a bit slow lately and I would like to try some alternative.
Hey Damian!
I made the same switch a few years back, and never looked back. I’m mostly using git hooks for pushing now. I’ve got a repo on how to do it on github here.
That being said, I also use Filezilla or SCP on the command line if I need to push something one off.
Link to commentThanks for posting this! Almost a full year after you put it up, it’s exactly what I needed 🙂 One thing to add for future Googlers:
Sublime needs to recognise your current file as markdown for the `PrefÂerÂences > SetÂtings — More > SynÂtax SpeÂcific — User` to work properly. Sublime doesn’t come with Markdown installed by default, so you’ll need to install a package that includes Markdown (I used MarkdownEditing). After that you can set your .md file to markdown and then follow these instructions from here.
Thanks again!
Link to commentThanks a ton Lucy! This is a fantastic suggestion.
Link to commentThanks, dude! Great fix. 🙂
Link to commentThanks. Wonderful.
Link to commentThank you! It’s helpful. And I want to mention a tip. Only the config file’s title is “MultiMarkdown.sublime-settings” can work. If the title is “JSON.sublime-settings”, it can’t worked. You need open “Syntax Specific” once again.
Link to commentHelpful tip mate!
Link to comment