I was wondering what would be the fastest way to output ‘console.log’.
The autocomplete usually takes a few key presses and typing starting from ‘con’ and I was wondering what the fastest way to do this would be. Maybe through a custom hotkey?
Thanks
Quick way to type console.log?
The fastest way would be a keybinding, but there’s also snippets: https://www.sublimetext.com/docs/completions.html
Going the snippet route, example would be the following, which you can put in place with Tools > Developer > New Snippet
. As a key you would use the insert_snippet
command with an argument of contents
that is the textual content of the snippet that should be inserted).
I use this one and have a version with the same tab trigger and different scopes for all of the languages that I regularly use that expands out to the appropriate way to log in that thing, so that the muscle memory of cw<tab>
works everywhere.
Key bindings can similarly use context
to only apply in certain file types, but I personally find that snippets keep me “in the flow” because this one comes up pretty often.
<snippet>
<content><![CDATA[
console.log('$1');$0
]]></content>
<tabTrigger>cw</tabTrigger>
<scope>source.ts, source.js</scope>
</snippet>
This is what I do. Create a utils.js file, in it put this
export const log = (content) => {
console.log(content);
};
Import it into your JS file, then just type “log” and tab. Then it is not restricted to one editor
example
log(variable) tab
I have a lot of other exports that do work for me like propercase names, addEventListener etc