gpt4 book ai didi

emacs - 如何在 evil-mode 下获得简单的导航窗口运动?

转载 作者:行者123 更新时间:2023-12-04 10:51:14 25 4
gpt4 key购买 nike

在 vim 我的 .vimrc 中有这个:

" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l

如何在 evil-mode 下获得简单的窗口导航?

另外,在 vim "+ 中会复制到我的系统剪贴板吗?这似乎在 emacs 中不起作用。
$ emacs --version

GNU Emacs 24.3.1 Copyright (C) 2013 Free Software Foundation, Inc. GNU Emacs comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of Emacs under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING.


$ cat .emacs

;;
;; Package manager and better repos
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)

(setq backup-directory-alist `(("." . "~/.emacs.d/saves")))

;; Indents, tab as spaces
(setq-default indent-tabs-mode nil)
(setq default-tab-width 2)

;; evil-mode
(eval-after-load "evil"
'(progn
(define-key evil-normal-state-map (kbd "C-h") 'evil-window-left)
(define-key evil-normal-state-map (kbd "C-j") 'evil-window-down)
(define-key evil-normal-state-map (kbd "C-k") 'evil-window-up)
(define-key evil-normal-state-map (kbd "C-l") 'evil-window-right)))
(require 'evil)
(evil-mode 1)
;(setcdr evil-insert-state-map nil)
;(define-key evil-insert-state-map [escape] 'evil-normal-state)

;; Fun stuff
(require 'jabber-autoloads)
(require 'jabber)

最佳答案

您可以将要使用的键绑定(bind)添加到 evil-normal-state-map :

(eval-after-load "evil"
'(progn
(define-key evil-normal-state-map (kbd "C-h") 'evil-window-left)
(define-key evil-normal-state-map (kbd "C-j") 'evil-window-down)
(define-key evil-normal-state-map (kbd "C-k") 'evil-window-up)
(define-key evil-normal-state-map (kbd "C-l") 'evil-window-right)))

将代码包装成 eval-after-load有必要确保 evil-normal-state-map在调用 define-key 时定义/可用.

如果您想让相同的绑定(bind)在其他“状态”(例如“运动”状态)中也可用,只需将它们添加到相应的键映射中,如上所示(在“运动”状态的情况下,相应的映射是称为 evil-motion-state-map )。

要让 Emacs 使用系统剪贴板,请尝试设置 x-select-enable-clipboard到非 nil值(value):
(setq x-select-enable-clipboard t)

还有一些使用剪贴板的特定命令用于杀死和拉拽。从文档中:
  • clipboard-kill-region :

    Kill the region, and save it in the X clipboard.

  • clipboard-kill-ring-save :

    Copy region to kill ring, and save in the X clipboard.

  • 关于emacs - 如何在 evil-mode 下获得简单的导航窗口运动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23578102/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com