Code Highlighting in Evernote... Kinda

A while back, Evernote for Mac added Code Blocks. To enable this feature, you cannot use the App Store version of Evernote.

In addition, you have to check Enable Code Block in Preferences


Code blocks were okay, allowing you to do nice simple stuff maintaining your plain text formatting like this:

func commonInit() {
self.backgroundColor = UIColor.black;
let imageView = UIImageView(image: UIImage(named: "splash.png")!)
imageView.contentMode = .scaleAspectFit
self.addSubview(imageView)
constrain(self, imageView) { me, imageView in
imageView.size == me.size
imageView.center == me.center
}
}

But there was no way to keep your colored syntax formatting (from Xcode, App Code and others) until Evernote 6.11 for Mac (or sometime like that).

Here's how to do it:
  1. Type one line of text
  2. Turn that into a code block
  3. Replace the contents of that code block with code you paste from Xcode
  4. That's it!


Stubbed Code Block

Stub a code block


Stubbed Code Block, Content Replaced

func commonInit() {
self.backgroundColor = UIColor.black;
let imageView = UIImageView(image: UIImage(named: "splash.png")!)
imageView.contentMode = .scaleAspectFit
self.addSubview(imageView)
constrain(self, imageView) { me, imageView in
imageView.size == me.size
imageView.center == me.center
}
}


In Atom: Use Copy as RTF

The Copy as RTF package in Atom will make this work there too. Fun!