Hot answers tagged

28

The following snippet will make Evil treat an Emacs symbol as a word. (with-eval-after-load 'evil (defalias #'forward-evil-word #'forward-evil-symbol) ;; make evil-search-word look for symbol rather than word boundaries (setq-default evil-symbol-word-search t)) This has the advantage that it changes depending on the language: foo-bar is one ...


28

There is no bug here. Since I was also annoyed with this behavior, I just read Evil code to find out why this is happening. So, here is a straight copy/paste of the well-commented one-liner from my Emacs configuration that fixes this issue: ;; Imagine the following scenario. One wants to paste some previously copied ;; (from application other than Emacs) ...


26

The simplest workaround: use ciW to select a whitespace-delimited word. The bigger issue has to do with the value of the _ character in the syntax table. The issue is that _ is, by default, a symbol constituent in the syntax table, and you want to treat it as a word constituent. If you're using emacs 24.4, you could try enabling superword-mode. I haven't ...


16

Toggle You can toggle it off with (spacemacs/toggle-vi-tilde-fringe-off), you can get the list of all toggles in helm-spacemacs accessible via SPC f e h or SPC h SPC in more recent versions. Every toggle in this list have 3 functions associated to them, if we take vi-tilde-fringe then the functions are: spacemacs/toggle-vi-tilde-fringe (toggle the state on ...


15

Evil is basically a global minor mode that enables a few extra keymaps on top of Emacs and comes with the respective editing commands you'd use in them. It is intentionally built to reuse as much existing Emacs Lisp code as possible for better interoperability and less wasted effort, you'll for instance find out that window movement was lifted from windmove....


14

The spacemacs FAQ offers the following language-specific solution: ;; For python (add-hook 'python-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) ;; For ruby (add-hook 'ruby-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) ;; For Javascript (add-hook 'js2-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) It also works in regular emacs. With ...


14

Motion state is an Evil-specific thing, intended for modes where you don't edit text, but still want Vim-style movement available, with all other keys of that mode passing through. Help buffers are an example of such a case, the package.el listing is another one. Typically you want commands moving point in evil-motion-state-map and everything else in evil-...


12

Evil has the evil-define-key macro for defining commands for certain states in a specific keymap only: (evil-define-key 'insert emacs-lisp-mode-map (kbd "C-c C-c") 'butterfly (kbd "<pause>") 'zone) It is able to delay the execution of the binding (by using eval-after-load itself) and can also take more ...


11

Here's a workaround: (add-hook 'with-editor-mode-hook 'evil-insert-state) I'm not sure why the initial state system was chosen as it either means you have a huge whitelist of states or do lookup of derived modes, the hooks system is a much more natural fit for Evil IMO.


10

The variable cursor-type controls how the appearance of the cursor, defaulting to t, which uses the cursor specified for the frame (see the docstring for options). If you'd like the cursor to default to a block, you can (setq cursor-type 'box). However, evil provides a number of different cursors for the different states, which you can adjust to give you a ...


10

Since @shosti pointed out that Evil considers deviation from Vim behavior as bugs, I filed a bug and one of the authors of Evil added a new possible value for evil-want-fine-undo: (setq evil-want-fine-undo 'fine) With this setting, you get new undo units when moving the cursor in insert mode, but replace operations are undone in one step. As far as I can ...


10

I've got it working now, thanks to your answers: (defun my-jump-to-tag () (interactive) (evil-emacs-state) (call-interactively (key-binding (kbd "M-."))) (evil-change-to-previous-state (other-buffer)) (evil-change-to-previous-state (current-buffer))) (define-key evil-normal-state-map (kbd "C-]") 'my-jump-to-tag) This will set evil-state to "...


10

The official way of doing this is demonstrated in evil-maps.el. Therefore, creating a new ex command is very simple: (evil-ex-define-cmd "b[utterfly]" 'butterfly) You'll want to either use this after enabling Evil or alternatively after loading the respective file: (eval-after-load 'evil-ex '(evil-ex-define-cmd "b[utterfly]" 'butterfly)) Doing this ...


10

You can make the current line number show instead of "0" by customizing the linum-relative-current-symbol variable. You can change that variable by one of multiple ways. M-x customize-group RET linum-relative RET From there, customize the "Linum Relative Current Symbol" variable (whose default value is 0). If you hit on the "More" link, below it, the ...


10

First of all, in Emacs one thinks in keymaps and commands, not so much keys in their (original) context. Your first step would be figuring out how the commands are named in Evil's normal and visual state (F1 k), then what keymap they're bound to (just look through evil-maps.el with M-x find-library). Armed with this knowledge, accomplishing this is fairly ...


9

In smartparens-mode, the function sp-up-sexp will move you out of a set of parentheses (bind to your key of choice): Move forward out of one level of parentheses. ... Examples: (foo |(bar baz) quux blab) -> (foo (bar baz) quux blab)| (foo (bar |baz) quux blab) -> (foo (bar baz) quux blab)| ;; 2 (foo bar |baz -&...


9

"Moving one space left after leaving insert" is the default behavior in Vim, which evil (on top of which spacemacs is built) emulates by default. If you don't like that behavior, you can set (setq evil-move-cursor-back nil).


9

The state can be accessed via evil-state, eg: (cond ((eq evil-state 'visual) (do-something)) ((eq evil-state 'normal) (do-other-thing)) ((eq evil-state 'insert) (do-another-thing)))


8

Here is one way of doing it that uses built-in functionality only: With point in the line that contains first occurrence of begin, press C-SPC. Move to next occurrence of end: C-s end RET Replace foo with bar: M-% foo RET bar RET ! This makes use of the fact that query-replace will work on the active region instead of the whole buffer if there is one. ...


8

You can set evil-default-state to emacs. The docstring reads: Documentation: The default state. This is the state a mode comes up in when it is not listed in evil-emacs-state-modes, evil-insert-state-modes or evil-motion-state-modes. The value may be one of normal, insert, visual, replace, operator, motion and emacs. Hence: (setq evil-...


8

Org-mode is built-in to Emacs 24.5.1, so there's no need to eval-after-load. with-eval-after-load is also preferred over eval-after-load. Instead of trying to remap org-kill-line, why not just specify C-k? (define-key org-mode-map (kbd "C-k") nil) Also, there may be other modes that bind a common key like C-k. Instead, you can use C-c k. The C-(letter) ...


8

Credits to awalker4 from reddit! (add-hook 'org-capture-mode-hook 'evil-insert-state)


8

evil has two search implementations, one is its own, the other one is a wrapper around emacs isearch. evil-search-forward wraps isearch-forward, evil-ex-search-forward invokes the internal search. Which one is used is governed by the variable evil-search-module, the default is isearch. In this mode, evil's search behaves exactly like emacs' (because it is.) ...


8

The package evil-numbers does exactly what you need.


7

evil provides a stripped-down version of ex, so it's probably best to presume that it's not an exact drop-in. However, the example you provided works out of the box, provided that point is prior to the first line (ie, the begin line in your example).


7

You should also be able to C-z to enter normal emacs mode, and then another C-z to go back to evil.


7

This might not be exactly what you want, but there is a way to execute one command and then return to insert state. Press C-o (evil-execute-in-normal-state) which puts you in a state where the next keybinding will be executed in normal state, and then you will be returned to insert state. For example, while in insert state, press C-o and then SPC f y. This ...


7

The reason this fails is because help-mode is in evil-motion-state-modes by default, adding it to evil-emacs-state-modes will therefore not have the desired effect as Evil looks it up in evil-motion-state-modes first to determine the initial state. The correct way to change the initial state of a mode is by using evil-set-initial-state: (evil-set-initial-...


7

The author of undo-tree.el, Toby Cubitt, is presently too busy to fix this particular bug. If he has time in the future, he may look into the issue further. The author has indicated that he has difficulty reproducing the error reliably, and was recently unable to reproduce it using the master branch. It only occurs when using undo/redo-in-region. The ...


6

Add this to your init.el (setq inhibit-startup-screen t) (setq initial-scratch-message ";; Message goes here") The first bit hides the startup screen, so the default buffer when you open emacs will *scratch*. The second lines sets the default contents in the scratch buffer.


Only top voted, non community-wiki answers of a minimum length are eligible