helix icon indicating copy to clipboard operation
helix copied to clipboard

Add command to read file contents into current buffer (vim's `:r`)

Open pinpox opened this issue 3 years ago • 2 comments

I often use :r filename.txt to read a file into the current buffer on vim, but I could't find this feature in helix. There is shell_insert_output and shell_append_output which can be used together with cat to simulate this, but that has the drawback of not supporting things like tab-completion for paths and seems too complicated for such a basic feature.

My suggestion would be to either add a file_insert/append_contents or even better to use the existing file-picker dialog (<space>-f) and expand it's functionality with a shortcut to paste in the contents of the selected file, e.g.:

  1. Open picker <space>-f
  2. Type part of filename until it's selected
  3. Press <Ctrl>-o or <Ctrl>-O> to paste contents of selected file at end/beginning of current buffer (or any other choosen key)

Furthermore, the :r (or :read) commands don't exist yet and would therefore not interfere with anything existing, I think it would be good idea to add those.

pinpox avatar Sep 11 '22 08:09 pinpox

Yes please!

gdamore avatar Sep 30 '22 22:09 gdamore

I will give this issue a shot 👍 Could I just clarify the requirements? @pinpox Based on my understanding, you seem to have 2 different ideas of solving this issue.

  1. opening the picker and then using ctrl-o
  2. using the vim style of :read

Are you proposing to do both?

Thank you!

edit: Only realised after submitting a PR that there are already 2 ongoing PRs for this issue. But I'll leave this here nonetheless(: Happy to receive any feedback.

zephaniahong avatar Oct 15 '22 08:10 zephaniahong