helix
helix copied to clipboard
Auto-save
So, hmm, I found that it's hard to write Rust on Helix, because the rust-analyzer won't give me the informations about borrow checking, ownership and many other things unless I save my file. In VSCode I can enable the auto-save so it's OK for me, but in helix I can't find a way to enable auto-save. It's really inconvenient to type <ESC> :w <Return> i after typing each line of the code. I think it's necessary for helix-editor to offer an option to enable/disable auto-save. Thanks a lot.
In the meantime, you could bind saving the file to a keybind while in insert mode. For example, you can use Ctrl-s to save while in insert mode using this binding in your config.toml (accessible via :config-open):
[keys.insert]
"C-s" = ":w"
What would you want to trigger the auto-save? Some amount of idle time?
iirc rust-analyzer plans to add on the fly diagnostics (no idea when)
https://github.com/helix-editor/helix/pull/3178
In the meantime, you could bind saving the file to a keybind while in insert mode. For example, you can use
Ctrl-sto save while in insert mode using this binding in yourconfig.toml(accessible via:config-open):[keys.insert] "C-s" = ":w"
well, it looks not working for me
What would you want to trigger the auto-save? Some amount of idle time?
just like what vscode does
Some of us never used vscode so you'll have to elaborate.
https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save
Looks like there are different auto save modes.
https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save
Looks like there are different auto save modes.
afterDelay, i mean
What would you want to trigger the auto-save? Some amount of idle time?
Something that worked well for me in nivm is on reentering normal mode. This means that it gets saved after basically every change.
EDIT: This also partially solves the issue of the IDE (or language server) screaming at me about an unfinished line of code while I'm writing it.
In addition to what @TobTobXX suggested, which also was part of how I had nvim setup, I propose that also changing to a different split or buffer might be a good time to save the buffer that was moved away from.
I guess that maps closely to the vscode onFocusChange
In the meantime, you could bind saving the file to a keybind while in insert mode. For example, you can use
Ctrl-sto save while in insert mode using this binding in yourconfig.toml(accessible via:config-open):[keys.insert] "C-s" = ":w"well, it looks not working for me
For me, with helix 22.08.1 (66276ce6), this does work but it looks like it doesn't, because it doesn't clear the "modified" bit in the buffer list or the [+] in the status line.
However if you cat the file from another terminal you'll see your changes actually were saved.
This might be #2192.
oh really? I'm going to have a try.
Something that worked well for me in nivm is on reentering normal mode. This means that it gets saved after basically every change.
This is problematic when using auto formatting.
E.g. if you open and close a block, then enter normal mode to navigate and insert somewhere in the block, then the formatted will already have collapsed the entire block into {}.
At least a delay is necessary.
Hurry up guys, I lost lots of records on a note about helix using helix within a broken down of a laptop.
Just FYI there is an autosave on focus lost setting you can turn on which will save the document when your cursor is outside the terminal(sorry if you already know about this)
[editor]
auto-save = true
#5303 solves this
This comment does it in a unique way: autosaving whenever pressing escape / exiting out of insert mode.