Multi-cursor Goodness

You may already be familiar with Sublime Text’s ability to have multiple cursors, but did you know you could use them in your snippets as well? Having identical fields in a snippet is called “Mirrored Fields” and comes in really handy when doing a console.log() in JavaScript. For example, if you wanted to log a message with variable’s name as a string and the actual variable at the same time.

Snippet Video

Adding the Snippet

Go to Tools > New Snippet… and paste in the following:

<snippet>
	<content><![CDATA[
console.log("$1"${2:,$1});
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>clog</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>

How to use it

Type clog and hit the tab to trigger the snippet. Once triggered, use the multi-cursor to simultaneously type the variable name and it’s output. If you only want to output a string, tab once more to highlight the variable and delete it.