Sublime Forum

Auto-replace/auto-format as you type?

#1

I’ve been using snippets and completions and they’re a great feature and certainly have their uses. What I’m curious about, however, is a feature to auto-replace/format text as I type it. Specifically, I’m imagining case-conversion. I use a number of languages where TitleCase or camelCase is the norm. Let’s take JavaScript, for example. Is there a feature or plugin that could convert the following text after I finish typing the name?

isnan   ==> isNaN
charat  ==> charAt

I guess it would be similar to a completion but one that works automatically after the entire “trigger” is typed and without requiring the use of [Tab]/[Enter]?

It would be great if it was regex-definable or would at least consider word borders like parens so that function names, arrays, etc. would work properly. For example:

isnan(      ==> isNaN(
isnandgate  ==> isnandgate    // "isnan" does not occur between word borders. No substitution.

Does anyone have any suggestions for plugins or features native to Sublime that could accomplish this type of request?

Thanks.

0 Likes

#2

Doesn’t the inbuilt autosuggest help you out here? With things I type repeatedly, eg. variable, constant & function names, sublime’s autosuggest gives you a list when you start typing a few letters. It will remember your favourites as defaults, and you quickly learn to use a few keys and tab to get those awkward words after a while. eg, for isNaN i just type inn. You should only have to type it “properly” once.

Nonetheless, the only Autocorrect I’ve seen activates on . I imagine it wouldn’t be too hard to fork that plugin to add scope sensitivity and act upon any word separator.

:smile:

0 Likes

#3

Yes, the built-in autosuggest would bring up “isNaN” from a previous occurrence. As it is, I already have “isNaN” defined as a completion so it brings it up even w/o having been used previously. But it won’t automatically correct the case unless I hit [Tab]. So I’m looking for a feature like completions but one that occurs automatically as I type, w/o the need for acceptance (tab). Take any of the VB languages (VB6, VBA, VBScript, VB.NET), for example, which use TitleCase for their keywords (not a requirement, but in practice) . “If”, “Do”, “As”, “In”, “To”, etc. are all keywords where hitting [Tab] wouldn’t make much sense. After all, I’m only entering two letters.

I’ll see if I can find the autocorrect plugin you’re referring to and see if it can be adapted to accommodate my requirements. Thanks.

0 Likes