Linux 下使用 Capslock 当作 Ctrl_L, 输入法切换中英文。(使用 xremap)

下面是我完整的 xremap Emacs 配置,供大家参考:

modmap:
  - name: Global except Emacs
    application:
      not: Emacs
    remap:
      CapsLock:
        held: Ctrl_L
        alone: KEY_LEFTSHIFT
      Alt_R: Capslock
  - name: use Shift switch im in emacs
    application:
      only: Emacs
    remap:
      Capslock:
        held: Ctrl_L
        alone: F8 # F8 binding to toogle-input-method in emacs
      Alt_R: Capslock

keymap:
  - name: Emacs
    application:
      not: [konsole, Emacs, Bcompare4]
    remap:
      # Cursor
      C-b: { with_mark: left }
      C-f: { with_mark: right }
      C-p: { with_mark: up }
      C-n: { with_mark: down }
      # Forward/Backward word
      M-b: { with_mark: C-left }
      M-f: { with_mark: C-right }
      # Beginning/End of line
      C-a: { with_mark: home }
      C-e: { with_mark: end }
      # Page up/down
      M-v: { with_mark: pageup }
      C-v: { with_mark: pagedown }
      # Beginning/End of file
      M-Shift-comma: { with_mark: C-home }
      M-Shift-dot: { with_mark: C-end }
      # Newline
      # C-m: enter
      # C-j: enter
      C-o: [enter, left]
      # Copy
      C-w: [C-x, { set_mark: false }]
      M-w: [C-c, { set_mark: false }]
      C-y: [C-v, { set_mark: false }]
      # Delete
      C-d: [delete, { set_mark: false }]
      M-d: [C-delete, { set_mark: false }]
      # Kill line
      C-k: [Shift-end, C-x, { set_mark: false }]
      # Kill word backward
      Alt-backspace: [C-backspace, C-x, {set_mark: false}]
      # Undo
      C-slash: [C-z, { set_mark: false }]
      C-Shift-ro: C-z
      # Mark
      C-2: { set_mark: true }
      # Search
      C-s: F3
      # C-r: Shift-F3
      M-Shift-5: C-h
      # Cancel
      C-g: [esc, { set_mark: false }]
      # C-x YYY
      C-x:
        remap:
          # C-x h (select all)
          h: [C-home, C-a, { set_mark: true }]
          # C-x C-f (open)
          C-f: C-o
          # C-x C-s (save)
          C-s: C-s
          # C-x k (kill tab)
          k: C-f4
          # C-x C-c (exit)
          C-c: C-q
          # C-x u (undo)
          u: [C-z, { set_mark: false }]

这里假设你使用的输入法是 fcitx, 并且没有更改切换中英文的配置选项,默认该输入法使用 Shift 切换中英文。 另外你需要将 Emacs 里面的 toggle-input-methd 全局绑定到 F8 (任何空键均可,只要和上面配置中的 F8 一致即可

好啦, 你终于可以释放掉你 Ctrl + Space 以及 Ctrl + \ 做其他用啦

忘记说了,上面的配置,还将右侧的 Alt 改为了原始的 Capslock, 所以,你什么也没有失去!

6 个赞

妙不可言,抄走了。小花花送上