Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

A way to insert text with (insert mode) keymapping #2797

Closed
tmke8 opened this issue Jun 17, 2022 · 4 comments
Closed

A way to insert text with (insert mode) keymapping #2797

tmke8 opened this issue Jun 17, 2022 · 4 comments
Labels
C-enhancement Category: Improvements

Comments

@tmke8
Copy link

tmke8 commented Jun 17, 2022

For markdown files, I like to have a keybinding where when I type `p it's expanded to ```python (similarly, `r to ```rust and so on).

Currently, I do this with

[keys.insert]
"`" = { p = ["normal_mode", ":pipe echo '```python'", "collapse_selection", "insert_mode"] }

This does work, but it seems a bit convoluted.

As far as I know there is currently no other way. (Correct me if I'm wrong.)

I would imagine a solution like this:

[keys.insert]
"`" = { p = ":insert_text ```python" }

EDIT:
The current work-around is

[keys.insert]
"`" = { p = [":insert-output echo -n '```python'"] }
@tmke8 tmke8 added the C-enhancement Category: Improvements label Jun 17, 2022
@the-mikedavis
Copy link
Member

You could simplify that keymap with :insert-output/:append-output #2589

It's probably best to solve this with #1383 in the long run.

@tmke8
Copy link
Author

tmke8 commented Jun 17, 2022

Ah, I was using release 22.05 so I didn't have those commands. Sorry!

@tmke8 tmke8 closed this as completed Jun 17, 2022
@tmke8
Copy link
Author

tmke8 commented Jun 17, 2022

On closer inspection, those commands are also based on calling shell commands. So, it's basically the same issue with them.

@tmke8 tmke8 reopened this Jun 17, 2022
@sudormrfbin
Copy link
Member

I would say snippet support (#1178) is the best way to solve this since you want some text to expand to an arbitrary longer text.

@helix-editor helix-editor locked and limited conversation to collaborators Apr 7, 2024
@pascalkuthe pascalkuthe converted this issue into discussion #10212 Apr 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants