Skip to main content
24 votes

Github-flavored markdown mode: syntax highlight code blocks

Native syntax highlighting of code blocks is now part of the current development version of Markdown mode. Specifically, it works for those GFM or tilde-fenced code blocks for which the language name ...
Jason Blevins's user avatar
24 votes
Accepted

Export code blocks in org-mode with minted environment

You will need to tell Org to Use minted for listings Include minted in the default package list Change the compilation switches to accommodate for minted: (setq org-latex-listings 'minted ...
wasamasa's user avatar
  • 22.2k
13 votes

Can I highlight Lisp like this?

With show-paren-mode you can highlight the whole expression. You need to have the following code in your init file. You can try different style and choose what you like to highlight. (show-paren-mode ...
Hariharan's user avatar
  • 473
11 votes

Exporting highlighted source code to pdf in Org-Mode

Hey this answer solved my similar problem. A bit late but I had the same issue today. As mentioned, I add the following code snipped to my .spacemacs/.emacs config: (require 'org) (require 'ox-latex)...
Oyren's user avatar
  • 221
11 votes
Accepted

How to get colored syntax highlighting of code blocks in asynchronous Org-mode exports to HTML?

With ox-html? See the docstring of org-html-htmlize-output-type. Output type to be used by htmlize when formatting code snippets. Choices are css to export the CSS selectors only,inline-css to ...
rasmus's user avatar
  • 2,732
11 votes
Accepted

How to highlight in different colors for variables inside `fstring` on python-mode

I think this will do it for Emacs versions < 27.1 (require 'python) (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group ...
John Kitchin's user avatar
  • 11.9k
10 votes

Is there a standard mode for .ini files?

conf-mode.el says: This mode is designed to edit many similar varieties of Conf/Ini files and Java properties. It started out from Aurélien Tisné's ini-mode. conf-space-keywords were inspired ...
Stefan's user avatar
  • 26.5k
9 votes
Accepted

Fontify broken links in org-mode

In org-9 it might be as simple as this for file links: (org-link-set-parameters "file" :face (lambda (path) (if (file-exists-p path) 'org-link 'org-warning))) For internal links I don't know an ...
John Kitchin's user avatar
  • 11.9k
8 votes

Highlight current line without changing colours

Just for reference, try (set-face-attribute 'hl-line nil :inherit nil :background "gray6")
Yadoo86's user avatar
  • 81
8 votes

Syntax highlighting for comments starting with specific sequence of characters

This is what I ended up going with: (defface special-comment '((t (:foreground "#2aa198"))) "Cyan") (font-lock-add-keywords 'clojure-mode '((";-;.*" 0 'special-comment t))) ";-;.*" is regex. 0 ...
deadghost's user avatar
  • 827
6 votes
Accepted

How to syntax highlight Python f-strings so {...} uses regular code colors?

FWIW, I just pushed support for "proper" highlighting of f-strings in Emacs's master branch, so it will be available in Emacs-28 when that gets released (and is available in GNU ELPA's ...
Stefan's user avatar
  • 26.5k
6 votes

minor mode to display long integers?

I did some searching and surprisingly couldn't find any existing minor modes that seemed to do this. I thought it would be a fun little project, however, so I've written a minimal minor mode (rainbow-...
D. Gillis's user avatar
  • 496
5 votes
Accepted

Treat shebang as a comment

Try (modify-syntax-entry ?# ". 1" js-mode-syntax-table) (modify-syntax-entry ?! ". 2b" js-mode-syntax-table) Reference
Michael Vehrs's user avatar
5 votes

How to get semantic syntax highlighting on emacs for C/C++ code

color-identifiers-mode does this for variables, if I understand your question correctly. rainbo-identifiers-mode too, I think. Screenshot is from the former one.
Alejandro Erickson's user avatar
5 votes

Highlight current line without changing colours

This is the case by default for me: hl-line-mode by default uses a face which only specifies a background color. That face is hl-line which by default just inherits from highlight. So maybe the ...
Stefan's user avatar
  • 26.5k
5 votes

Highlight current line without changing colours

This works for me, with this in my .emacs. See how the syntax colours are nicely preserved? (thx Yadoo86) ;; highlight line with the cursor, preserving the colours. (set-face-attribute 'hl-line nil :...
ohainaut's user avatar
5 votes

Adding new commands to the syntax highlighting of a language mode

You can do this using the function font-lock-add-keywords. It takes two arguments, the first is the major mode to extend. Alternatively, you can pass nil which mean the current buffer, which is useful ...
Lindydancer's user avatar
  • 6,180
5 votes
Accepted

Don't switch to math-mode when entering `$` in a `minted` environment

You can add minted environments to the latex-verbatim-environment variable: M-x customize-variable latex-verbatim-environments, insert a new string "minted", and save your changes. You may need to ...
Tyler's user avatar
  • 22.4k
5 votes
Accepted

How to highlight graphql template literals (gql) in js(x) files?

I've found a solution using the emacs package mmm-mode. Most of the information I got was from this article. What this package does, is allow multiple major modes in the same buffer. You basically ...
andykais's user avatar
  • 166
5 votes
Accepted

Why does text surrounded by tildes in org mode turn grey

Tildes are used for marking something as code/monospace. See Emphasis and monospace in the Org manual. Your whole buffer might be monospace in Emacs (depending on your settings) so the gray is a ...
glucas's user avatar
  • 20.7k
5 votes

org-mode batch export: Missing syntax highlighting

You have already mentioned that emacs skips the personal initialization files if it is called with --batch. Therefore, you need to call package-initialize yourself if you want to use package.el. ...
Tobias's user avatar
  • 33.4k
5 votes
Accepted

How does org-mode implement syntax highlighting for code blocks?

It uses cc-mode. It copes the text to a temporary buffer, highlights it using the major mode that is associated with the language, and copies back the highlighting. In addition, it makes everything ...
Lindydancer's user avatar
  • 6,180
4 votes
Accepted

add a rule to syntax-propertize-rules

The answer is that you can't do it "right". But you can do the following: (defalias 'my/perl-syntax-propertize-function (syntax-propertize-rules ("\\('\\)[bh]" (1 ".")))) (add-hook 'perl-mode-hook ...
Stefan's user avatar
  • 26.5k
4 votes

Don't switch to math-mode when entering `$` in a `minted` environment

I'd like to give an answer which is complementary to the one given by @Tyler. I'd recommend that you set this in your init file: (setq TeX-parse-self t) restart your Emacs and open your .tex file ...
Arash Esbati's user avatar
  • 2,030
4 votes
Accepted

Syntax highlight doxygen comments in C/C++? (c-doc-comment-style)

Posting own answer since I didn't find an existing method *. This is generic Doxygen highlighting, it doesn't try to be too strict since doxy supports so many different expressions. \[anything] and @...
ideasman42's user avatar
  • 8,925
4 votes

How to change syntax highlighting for mode?

In Emacs, syntax highlighting is performed using the module font-lock. It highlights a buffer in two phases: The syntactic phase, where comments and strings are highlighted. The keyword phase, where ...
Lindydancer's user avatar
  • 6,180
4 votes
Accepted

How to activate AUCTeX support for beamer without preamble?

First of all, I suggest you create a proper class file beamer-preamble.cls like this: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{beamer-preamble} [2017/04/26 v0.1 My Beamer Preamble] \LoadClass[<...
Arash Esbati's user avatar
  • 2,030
4 votes

How to highlight the current scope with C family languages?

A bit long in the tooth, but still seems to work fine, highlight-sexp will do what you want. Move out of your inner if, it highlights the entire for block. Out again, the entire outer if. Out again, ...
nega's user avatar
  • 3,276
4 votes

Defining color for "$"variable in bash

Emacs calls syntax highlighting “font lock”. Specifically, font lock is the part of syntax highlighting that parses the text to determine what parts are comments, keywords, variable names, etc., and ...
Gilles 'SO- stop being evil''s user avatar

Only top scored, non community-wiki answers of a minimum length are eligible