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

Implement New Line (O/o - "open") in Vi-mode #7442

Closed
joallard opened this issue Oct 31, 2020 · 5 comments
Closed

Implement New Line (O/o - "open") in Vi-mode #7442

joallard opened this issue Oct 31, 2020 · 5 comments

Comments

@joallard
Copy link

One of my commands in Vi is 'open': quite practical, it inserts a new line below or above the current cursor, and starts insert mode there.

This is an enhancement ticket to track this feature.

Quoting the Vim docs:

							*o*
o			Begin a new line below the cursor and insert text,
			repeat [count] times.
			[...]

							*O*
O			Begin a new line above the cursor and insert text,
			repeat [count] times.
			[...]

Current workaround: Alt+Enter. Not bad! Though it splits at current cursor position.

Equivalent commands: o: A<Enter>, O: I<Enter><Up>

I'm not much familiar with Fish source, does someone know what implementing this would entail? Unless I'm mistaken, it doesn't sound too complex.

[enhancement] [vi-mode]

@ridiculousfish
Copy link
Member

The basic steps are:

  1. Add a new readline command in input_common.h
  2. Implement it in handle_readline_command
  3. Add it to default vi bindings in fish_vi_key_bindings

@tamis-laan
Copy link

The basic steps are:

  1. Add a new readline command in input_common.h
  2. Implement it in handle_readline_command
  3. Add it to default vi bindings in fish_vi_key_bindings

If I would like to implement ci" ci( etc, where should I specify this?

@ridiculousfish
Copy link
Member

Take a look inside fish_vi_key_bindings.fish, you can see how some other vim bindings are implemented.

@reach-satori
Copy link

0001-vi-mode-o-and-O-commands.patch.txt
I didn't wanna do a whole pull request for this because it's indeed very simple, plus I'm new to contributing. But here's a patch file if anyone wants to do something with it. (with modified filename, since github doesn't like .patch ending files).

All it took was repeating the beginning-of-line and end-of-line cases and adding a newline character afterwards.

ridiculousfish added a commit that referenced this issue Dec 19, 2020
This is for symmetry with insert_line_under. See #7442.
@ridiculousfish
Copy link
Member

Thank you, merged as 2d2efc8. Though I accidentally gave credit in the commit to the bug filer joallard, instead of @reach-satori - sorry about that!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants