문제

Here is a receipe from vim tips:

# /usr/share/themes/Vi/gtk-2.0-key/gtkrc
# A key-binding set for vi-like key-bindings

binding "gtk-vi-text-view"
{
  bind "<ctrl>d" { "move-cursor" (display-lines, 5, 0) }
  bind "<ctrl>f" { "move-cursor" (display-lines, 5, 0) }
  bind "<ctrl>u" { "move-cursor" (display-lines, -5, 0) }
  bind "<ctrl>b" { "move-cursor" (display-lines, -5, 0) }
  bind "<ctrl>e" { "move-cursor" (display-lines, -1, 0) }
  bind "<ctrl>y" { "move-cursor" (display-lines, 1, 0) }
  bind "j" { "move-cursor" (display-lines, 1, 0) }
  bind "k" { "move-cursor" (display-lines, -1, 0) }
  bind "l" { "move-cursor" (logical-positions, 1, 0) }
  bind "h" { "move-cursor" (logical-positions, -1, 0) }
}

binding "gtk-vi-tree-view"
{
  bind "j" { "move-cursor" (display-lines, 1) }
  bind "k" { "move-cursor" (display-lines, -1) }
  bind "l" { "move-cursor" (logical-positions, 1) }
  bind "h" { "move-cursor" (logical-positions, -1) }
}

class "GtkTextView" binding "gtk-vi-text-view"
class "GtkTreeView" binding "gtk-vi-tree-view"

# The last part is to note your local gtk configuration file. Check in your home directory file named '.gtkrc-2.0'. and "touch" it. The only thing left to be done is appending:

gtk-key-theme="Vi"

This is all fine, but the problem is, under this configuration it's no longer possible to input the letters h, j, k and l. How can this be solved?

도움이 되었습니까?

해결책

You have missed the elephant in the room: Vi(m) is a modal editor while the GtkTextView widget is rather obviously not.

Non-modal editors or textfield widgets like the one you are playing with have their own way of handling the alpha-numerical keys of your keyboard: modifier keys.

Either

  • you hit a key to enter some kind of mode where you can hit hjkl without inserting them in your text

or

  • you press hjkl plus a modifier key.

Those are basically your only alternatives.

Using hjkl for cursor movement only makes sense when the user is in a mode that prevents him/her to insert what he/she types. It may "work" in GtkTreeView or in other contexts where the user is not expected to type text, though.

So… I'm not sure you really gave much thought to your problem.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top