I use yasnippet in orgmode to expand codeblocks of Python and start typing code. My snippet is defined as:

# -*- mode: snippet -*-
# name: emacs-jupyter code block for python (silent)
# key: <spp
# --
#+BEGIN_SRC jupyter-python :session py :results silent output :async yes

When I create the snippet and expand it, the cursor is positioned at the $1 so I can start typing. Pressing TAB again positions the cursor after #+END_SRC.

Problem: After pressing <spp TAB, I can start typing, but yasnippet displays the text being typed in green, instead of using the colors for the Python language: 1 The correct colors are only displayed after pressing TAB again to finish typing, or manually moving the cursor out of the code block: 2

Question: How can I disable the green color yasnippet is using?


Probably just change $1 to $0. That will just put the cursor there to start typing.

From the documentation:

Tab stops are fields that you can navigate back and forth by TAB and S-TAB. They are written by $ followed with a number. $0 has the special meaning of the exit point of a snippet. That is the last place to go when you've traveled all the fields.

Instead of using $1, using $0 implies that after expanding the snippet (i.e., <spp TAB), the cursor will be placed at $0, which is the exit point of the snippet. When the cursor reaches the exit point, the green highlighting disappears.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.