I am trying to make a template for React useState:
const [item, setItem] = useState('value')
const [$state$, set$state$] = useState($init$);$end$
Since item
is the same, only with a capital I, is it possible to auto-capitalize the first letter?
I am doing it in VS Code like this:
const [$1, set${1/(.*)/${1:/capitalize}/}] = useState($2)
Choose Template > New Variable from the editor toolbar (or choose an existing variable to add it to the page) Enter a name for the variable. Press Enter (by default this will create a single-line text input field)
To configure live templates, open the Editor | Live Templates page of the IDE settings Ctrl+Alt+S . On the Live Templates page, you can see all the available live templates, edit them and create new templates. To make finding and editing templates easier, they are split into groups.
One of my favorite tools in Android Studio (AS) is “Live Templates”. It is a way to create simple code templates that can be accessed via auto-complete shortcuts. Using them is a productivity booster, since they will automate a lot of boilerplate code for you.
Create a second variable whose value depends on the first one.
For example, $state_
has its value initialized to capitalize(state)
in the edit variables dialog
const [item, setItem] = useState('value')
const [$state$, set$state_$] = useState($init$);$end$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With