Missing auto-complete for the trailing semi-colon
As a programmer writing Rust in VS Code on Mac, I type
let s = String::from(
^
and the editor gives me a closing ) and places the cursor between the parens:
let s = String::from()
^
I then type a double quote:
let s = String::from(")
^
and the editor automatically adds a second " and places my cursor between the two quotes:
let s = String::from("")
^
I type in the text inside the double quotes, say “Hello, world!”:
let s = String::from("Hello, world!")
^
Here’s the problem: the cursor is now trapped after the text I typed, but still before the double-quote and the paren, but I need to add a semi-colon to close off the line. Here are my options:
right-arrow,right-arrow,;(three key strokes, but I need to move my hand away from the main board, which takes extra time))- (In Vim) Esc (to exit INSERT mode),
Shift+A(to bring the cursor to the end of the line and switch back to INSERT mode),;(four key-strokes, but I stay on the keyboard) - Lift one hand from the keyboard, move the mouse to the end of the line and left-click to place the cursor after the paren, then
;(only one keystroke, but my hand needs to leave the keyboard completely) - Type out the auto-completed characters (most editors will overwrite the auto-completed text):
Shift+'(to produce"on a UK layout keyboard),Shift+0(to produce)) (four key-strokes) Cmd+right-arrow,;(three key-strokes, but I have to move my hand)
Perhaps the least bad is option 2, but it only works in Vim.
I could enable one of the co-pilots to auto-complete for me, but there are cases when I’d still want it turned off (for example when learning, or when I don’t want my thinking interrupted or distracted). There’s also no guarantee it will always autocomplete the ;, and highly likely to produce extra characters or even logic that I have to then erase.
I could use a different editor altogether, possibly with smarter features, or buy a decent keyboard with an End key closer to the main part of the keyboard.
There’s also Prettier, but it’s mainly for JavaScript/front-end. While there are plugins for other languages, you may not be keen on giving access to a (however well intended) Github repo with 20 stars and one contributor.
When all other options are exhausted, there is the obvious (or not so obvious) solution: disable auto-complete altogether.
In VS Code, open user settings and add:
"editor.autoClosingQuotes": "never",
"editor.autoClosingBrackets": "never",
Typing the closing quote and paren out still takes three key-strokes (since you can hold down the Shift key while hitting ' and 0), but there is no longer a cognitive penalty caused by re-orienting myself after the machine added characters that interrupted your typing flow.
("");
Slow is smooth, smooth is fast.