Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-save #3451

Open
onion108 opened this issue Aug 15, 2022 · 18 comments
Open

Auto-save #3451

onion108 opened this issue Aug 15, 2022 · 18 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@onion108
Copy link

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.

@onion108 onion108 added the C-enhancement Category: Improvements label Aug 15, 2022
@Omnikar
Copy link
Contributor

Omnikar commented Aug 16, 2022

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"

@AceofSpades5757
Copy link
Contributor

What would you want to trigger the auto-save? Some amount of idle time?

@willparsons
Copy link

iirc rust-analyzer plans to add on the fly diagnostics (no idea when)

@archseer archseer changed the title hope to add auto-save Auto-save Aug 19, 2022
@archseer
Copy link
Member

#3178

@onion108
Copy link
Author

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"

well, it looks not working for me

@onion108
Copy link
Author

What would you want to trigger the auto-save? Some amount of idle time?

just like what vscode does

@archseer
Copy link
Member

Some of us never used vscode so you'll have to elaborate.

@kirawi
Copy link
Member

kirawi commented Aug 23, 2022

https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save

Looks like there are different auto save modes.

@onion108
Copy link
Author

https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save

Looks like there are different auto save modes.

afterDelay, i mean

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Aug 26, 2022
@TobTobXX
Copy link
Contributor

TobTobXX commented Sep 1, 2022

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.

@AfoHT
Copy link
Contributor

AfoHT commented Sep 22, 2022

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

@sourcefrog
Copy link

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"

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.

@onion108
Copy link
Author

onion108 commented Dec 1, 2022

oh really? I'm going to have a try.

@LeoniePhiline
Copy link
Contributor

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.

@6lj6
Copy link

6lj6 commented Dec 24, 2022

Hurry up guys, I lost lots of records on a note about helix using helix within a broken down of a laptop.

@gabydd
Copy link
Member

gabydd commented Dec 24, 2022

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

@ChemicalXandco
Copy link
Contributor

#5303 solves this

@dessalines
Copy link

This comment does it in a unique way: autosaving whenever pressing escape / exiting out of insert mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.