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

Rename buffers #4393

Closed
cor opened this issue Oct 20, 2022 · 6 comments · Fixed by #8584
Closed

Rename buffers #4393

cor opened this issue Oct 20, 2022 · 6 comments · Fixed by #8584
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@cor
Copy link
Contributor

cor commented Oct 20, 2022

It would be very nice if you could rename buffers from Helix.

For example, I'm editting a.txt within a project, and i need to rename it to b.txt.
Currently, you would:

  • <space>f -> a.txt
  • :w b.txt
  • quit helix
  • rm a.txt
  • open helix
  • <space>f -> b.txt

It would be much nicer if we had a rename command from within helix, so that you could simply:

  • <space>f -> a.txt
  • :buffer-rename b.txt

the buffer is now renamed to b.txt, while it is still open in your editor

@cor cor added the C-enhancement Category: Improvements label Oct 20, 2022
@cor
Copy link
Contributor Author

cor commented Oct 20, 2022

I don't have sufficient permissions in order to add labels, but this seems like a good first issue to me :)

@geometryolife
Copy link

There is also a slightly more complicated way what run shell commands in Helix:

:run-shell-command mv old_file_name new_file_name

I also agree with adding a build-in command or shortcut for Helix to change the file name.

@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much A-helix-term Area: Helix term improvements E-good-first-issue Call for participation: Issues suitable for new contributors labels Oct 25, 2022
@Elias-Graf
Copy link

Does this also rename references to the given file in code? I think https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_willRenameFiles is relevant.

That is also why @geometryolife suggestion does technically achieve renaming the file, but wouldn't accomplish what I would be expecting it to do.

@austinletson
Copy link

@cor @Elias-Graf there seems to be some discussion in the above linked issues as to what operations involving file management should be included in the editor as opposed to externally. What if instead of creating a new file/buffer and deleting the old file, there was a command that started a new buffer and saved the old buffers content to the new buffer but didn't delete the source file for the old buffer.

This is similar to the way :saveas works in vim: https://vimdoc.sourceforge.net/htmldoc/editing.html#:saveas

It seems like :write <file-name> already achieves this though. If I open a file and write to a different file, the buffer is renamed.

@cor
Copy link
Contributor Author

cor commented Jan 12, 2023

@austinletson in my opinion this really should be included in the editor. People primarily use Helix for creating code, and this process almost always involves renaming, deleting, and moving files. :saveas and :write are inferior solutions since they require the user to still manually delete the old file.

Also, like @Elias-Graf mentioned, this does not rename references to the file, which it should do.

One of the best features of Helix is the amazing out of the box LSP support, and properly renaming files really aligns with the current LSP feature set. It's also yet another advantage over vim and it also makes it easier for people coming from editors like Visual Studio Code to use Helix.

@ontley
Copy link
Contributor

ontley commented Jan 21, 2023

Well I implemented the command, now to wait for it to hopefully get merged

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 E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants