Ctrl+T should transpose previous two letters #128

Closed
jab opened this Issue Jun 13, 2012 · 6 comments

Comments

Projects
None yet
4 participants
@jab

jab commented Jun 13, 2012

...as in Emacs, bash, OS X text inputs, etc.

@crishoj

This comment has been minimized.

Show comment
Hide comment
@crishoj

crishoj May 17, 2013

Contributor

I have found myself missing the ability to transpose characters as well, and decided to take a stab at it. A few questions came up:

  • I assume implementing the transpose is a matter of defining e.g. R_TRANSPOSE_CHARS in input.h and handling it in the large command/input dispatch in reader.cpp. But how do I make sure that R_TRANSPOSE_CHARS is defined with a meaningful value? By carefully aligning the declaration in the enum in input.h?
  • Running fish with debug level 2, I can see that the keybinding code for CTRL+T is 20. But no keybinding code is reported for ALT+T ("transpose words"). How can I determine this keybinding code?
Contributor

crishoj commented May 17, 2013

I have found myself missing the ability to transpose characters as well, and decided to take a stab at it. A few questions came up:

  • I assume implementing the transpose is a matter of defining e.g. R_TRANSPOSE_CHARS in input.h and handling it in the large command/input dispatch in reader.cpp. But how do I make sure that R_TRANSPOSE_CHARS is defined with a meaningful value? By carefully aligning the declaration in the enum in input.h?
  • Running fish with debug level 2, I can see that the keybinding code for CTRL+T is 20. But no keybinding code is reported for ALT+T ("transpose words"). How can I determine this keybinding code?
@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag May 17, 2013

Contributor

What is the use case for this? Fixing typos? Anyway no need to go mess with the C++ code, all you need is this:

bind \ct 'commandline -t (commandline -t | sed -re "s/(.)(.)\$/\2\1/")'

which you can put in either ~/.config/fish/config.fish or funced fish_user_key_bindings; funcsave fish_user_key_bindings.

Contributor

dag commented May 17, 2013

What is the use case for this? Fixing typos? Anyway no need to go mess with the C++ code, all you need is this:

bind \ct 'commandline -t (commandline -t | sed -re "s/(.)(.)\$/\2\1/")'

which you can put in either ~/.config/fish/config.fish or funced fish_user_key_bindings; funcsave fish_user_key_bindings.

@dag dag referenced this issue May 17, 2013

Closed

vi mode missing #65

@crishoj

This comment has been minimized.

Show comment
Hide comment
@crishoj

crishoj May 18, 2013

Contributor

transpose-chars, transpose-words, and friends like upcase-word and downcase-word are text-editing commands that on one hand might seem slightly obscure in the sense that not every user is aware of their existence, but on the other hand something that one comes to expect from readline-ish tools as soon as one has benefited from their convenience a few times. See e.g. http://www.delorie.com/gnu/docs/readline/rlman_16.html for a list of very neat text-editing commands which pervade next to all wide-spread open source tools featuring a command prompt.

The effect is indeed achievable by customisation of the shell. But let's face it: The fish shell is so attractive because it works fantastically right out of the box with zero customisation. Supporting text-editing commands that habituated command-line users have come to expect is sufficient reason to go mess with C++ code, I think.

Contributor

crishoj commented May 18, 2013

transpose-chars, transpose-words, and friends like upcase-word and downcase-word are text-editing commands that on one hand might seem slightly obscure in the sense that not every user is aware of their existence, but on the other hand something that one comes to expect from readline-ish tools as soon as one has benefited from their convenience a few times. See e.g. http://www.delorie.com/gnu/docs/readline/rlman_16.html for a list of very neat text-editing commands which pervade next to all wide-spread open source tools featuring a command prompt.

The effect is indeed achievable by customisation of the shell. But let's face it: The fish shell is so attractive because it works fantastically right out of the box with zero customisation. Supporting text-editing commands that habituated command-line users have come to expect is sufficient reason to go mess with C++ code, I think.

@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag May 18, 2013

Contributor

Well if you do want to do it in C++ the right way would probably be to add new readline functions and then include defaults like bind \ct transpose-chars. That's probably what you were saying already, though. :-)

Does fish use GNU readline at all?

Contributor

dag commented May 18, 2013

Well if you do want to do it in C++ the right way would probably be to add new readline functions and then include defaults like bind \ct transpose-chars. That's probably what you were saying already, though. :-)

Does fish use GNU readline at all?

@crishoj

This comment has been minimized.

Show comment
Hide comment
@crishoj

crishoj May 20, 2013

Contributor

@dag, thanks for the pointer on the bindings! :-)

Contributor

crishoj commented May 20, 2013

@dag, thanks for the pointer on the bindings! :-)

@zanchey

This comment has been minimized.

Show comment
Hide comment
@zanchey

zanchey Jun 27, 2013

Member

I think this is fixed with merging of #792 and #840.

Member

zanchey commented Jun 27, 2013

I think this is fixed with merging of #792 and #840.

@zanchey zanchey closed this Jun 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment