/r/evilmode

Photograph via snooOG

This subreddit is for all things related to the Emacs Vim-style editor mode, Evil. Share links, ask questions, discuss ideas, anything so long as it's evil.

This subreddit is for all things related that most insidious of Emacs plugins, the Vim-style editor mode, Evil.

evil-mode is so different from Vim and Emacs that it's more like an editor all of its own. All the awesomeness of Emacs with the editing power of Vim.

Share links, ask questions, discuss ideas, anything, so long as it's evil. Feel free to repost evil related links from /r/emacs.

Links

/r/evilmode

943 Subscribers

1

Problem: using $ in visual mode goes one character beyond

While in visual mode, going to the end of the line with $ goes one character past the last character, so I can't go to the matching brace/parentheses/etc with %. It's weird that it doesn't happen in every mode: In typescript-mode it also goes one character beyond, but % does go to the matching thing. I was looking for evil|visual variables but can't find any that controls this.

0 Comments
2024/03/06
21:25 UTC

1

How to hide the mouse pointer in normal mode?

In Emacs + evil, when you type a character in insert mode, the mouse pointer automatically hides. It remains hidden until you move the mouse again, even if you switch back to normal mode.

Is there a way to replicate this behavior in normal mode? Specifically, can Emacs hide the mouse pointer whenever a key is pressed in normal mode?

This was not an issue for me when I was using X11 because I used unclutter to hide the mouse pointer. However, unclutter does not work on Wayland.

0 Comments
2024/01/02
19:38 UTC

2

Need Help with Configuring evil-set-leader locally

hi all, I'm trying to learn how to setup a few custom keybindings with a leader key for org mode when using evil but I'm hitting a roadblock and was wondering if someone could help what I'm doing wrong. If I use:

(evil-set-leader 'normal (kbd "SPC") nil) ;; sets the leader key globally it works, but if it set the localleader to true it does not.

Here is my init.el

(use-package evil
  :config
  (evil-mode 1))

(defun evil-org-keys ()
  (evil-set-leader 'normal (kbd "SPC") t)
  (evil-local-set-key 'normal (kbd "<leader>oa") 'org-agenda)
  (evil-local-set-key 'normal (kbd "t") 'org-todo)
  (message "evil-org-keys was run!")
)

(use-package org
  :after evil
  :init 
  (add-hook 'org-mode-hook 'evil-org-keys))

I have tried putting the hook after :config as well. In both cases when I run M-x org-mode I see it print "evil-org-keys was run!" but in neither case does the localleader work. I must be missing something simple

0 Comments
2023/12/13
20:32 UTC

3

Do people tend to just post in r/emacs instead of here?

Thought about posting some Evil-specific stuff, and noticed there's not a lot of conversation happening here... I'm not a big Redditor, and wanted to make sure I'm following reasonable norms... Should I cross-post to r/emacs, or just post there, or just here?

And: why do you think so little conversation happens here? Did r/doomemacs take over the Evil-specific discussion? Maybe there are just enough Evil users among Emacs folks that there's no reason to differentiate when you're posting about Evil-specific things—the Vanilla keybinders will just ignore the post?

Just curious! And trying not to be That Guy who doesn't know how to forum properly. : )

0 Comments
2023/11/17
17:26 UTC

4

Is there an evil-mode equivalent to nvim's Leap?

While my main editor is Doom Emacs, I have recently started dabbling with a neovim config, and came across this nvim plugin:

https://github.com/ggandor/leap.nvim

Which is pretty convenient to say the least, and has improved my speed significantly, at least on neovim.

I would like to integrate this type of behavior to my Emacs workflow. What would you guys recommend?

Thanks in advance :D

3 Comments
2023/01/05
06:33 UTC

2

In evil-mode, how to set "langmap" equivalent to use emacs to fluidly write and edit text in my native language and layout?

I'd like to use (spac)emacs to write and edit text in a language with a different alphabet (Cyrillic)

What I want is to be able to switch to Cyrillic layout and keep using the features of the editor. Obvious <a> for append and <c> for change work just fine using the C-\ keybinding.
However the <f> for find and </> search don't work as wanted: <f f> will try and find actual English letter "f" rather than Cyrillic letter <a> (that is placed over English < f > on the other layout) from the Cyrillic (Russian) layout.

In vim it was easy to set langmap as
set langmap=ФИСВ[...]ABCD[...]
and it'd handle the <f f> situation fine.

I tried evaluating (define-key evil-motion-state-map (kdb "a") 'evil-find-char)
and it worked but then I'm using the system-wide layout switch and lose the advantages of the C-\ way. I would then have to manually map every evil-mode function over to the Cyrillic map.

Is there a better way?

0 Comments
2022/11/29
05:00 UTC

4

Intro to Evil for non-Vim users? Beyond evil-tutor [x-post r/emacs]

I'm wondering, are there any guide or tutorials out there about Evil that are targeted at non-vim users? I'm particularly interested in what you get with the evil +everywhere module, ie evil and the essential packages you'd want for editing.

I've done evil-tutor but it's pretty limited. I'm in the situation where I'm trying to use vim keybindings because they hurt my wrists less than chords. I'm okay with hjkl, c, d, r, i, a, f, w, b but other than that I'm pretty clueless.

I don't want to read a bunch of vim tutorials only to find out they use a bunch of packages that work different than evil. And I'm looking for the common editing operations that aren't included in evil, like parens or s-exp manipulation.

1 Comment
2022/11/13
19:10 UTC

2

Map :W to :w into evil mode command line

I have a tendency to enter :W when saving a file and had this previously mapped accordingly in my Neovim setup:

local api = vim.api

local ex = setmetatable({}, {
  __index = function(t, k)
    local command = k:gsub("_$", "!")
    local f = function(...)
      return api.nvim_command(table.concat(vim.tbl_flatten {command, ...}, " "))
    end
    rawset(t, k, f)
    return f
  end
});

-- Replace built in command :W to :w
ex.cabbrev('W', 'w')
ex.cabbrev('Wq', 'wq')

How can I achieve the same thing in my Emacs Evil Mode setup?

2 Comments
2022/09/27
22:49 UTC

3

Evil - ci) doesn't work as expected

0 Comments
2022/09/21
04:16 UTC

3

Is there an equivalent to https://github.com/AndrewRadev/switch.vim?

Yo!

Essentially, switch.vim allows you to easily switch words for their alternative versions, like true -> false, foo -> bar -> baz.

It can also work contextually, for example during a git a rebase you can quickly switch between: pick -> fixup -> reword -> edit -> squash -> exec -> break -> drop -> label -> reset -> merge.

I wonder if there's a evil-mode port of this vim plugin?

6 Comments
2022/08/07
09:11 UTC

4

Is there a port or equivalent to vim-test for evil-mode?

Hi guys,

I've made the move from vim to Emacs with Evil-mode for a little while now, but still miss https://github.com/vim-test/vim-test. I wonder if there's a port for evil-mode or if you know of something closer to it you can recommend. Thanks

4 Comments
2022/07/29
05:54 UTC

6

How would one make a text-object based on multiple delimiters?

I want to create a motion that selects clojure's set: #{+}. The problem is that it's expected that it would be a character and not a string.

In the end I'd like to achieve something like this:

  (evil-define-text-object evil-eval-a-clj-set (count &optional beg end type)
    "Select and evaluate #{} in CIDER."
    :extend-selection nil
    (evil-select-paren "#{" ?} beg end type count t))
  (spacemacs/set-leader-keys-for-major-mode 'clojure-mode "e#" 'evil-eval-a-clj-set)
1 Comment
2022/04/14
08:39 UTC

4

Cursor colour

Hi, I am wondering if someone has been able to set cursor type in their init.el for a daemon-client setup. I have found no way to do this. My current implementation is:

(set-cursor-color "violet red")
(set-mouse-color "violet red")

;; evil mode hack
(setq
  evil-default-cursor t
  evil-normal-state-cursor 'box
  evil-insert-state-cursor 'bar)

However, I can't get the new frames to show in the right colour (it is blue). I have done an extensive google search and it only came up with some very old stackexchange articles. Any idea/comments/tips will be really appreciated, thank you!

0 Comments
2022/04/06
08:40 UTC

3

Ex command :up (or :update)

Does evil mode not implement the :up (short for :update) ex command? ... I'm using Doom emacs.

I'm used to it in vim instead of :w but on emacs I get the error: Unknown command 'update'.

2 Comments
2022/03/08
20:54 UTC

2

Recovering SPC as leader

In sunrise-commander, space is mapped to sr-scroll-quick-view.

I'd like to get <space> to be the leader again.
I tried removing it from the mode map

(define-key sr-mode-map (kbd "<SPC>") nil)

But then it's just unbound.

Help?

0 Comments
2021/12/04
01:16 UTC

4

Numbering via C-x r N (rectangle-number-lines function) does more than I want in Evil mode

Imagine I have the following text file:

abc
def
ghi

Lines 1-3 have text on them, and line four is blank.

I'm in normal mode with the cursor on 'a'.

If I use vip to select the paragraph object, and then C-x r N (rectangle-number-lines) to renumber the lines the trailing blank line is also renumbered, which is not what I wanted.

That is, instead of ending up like this:

1. abc
2. def
3. ghi

I get this:

1. abc
2. def
3. ghi
4.

I'm thinking this is an artifact of how the lines are selected in Evil mode, as when I try it in vanilla Emacs (and am careful to end my text selection on the "i" in the text file) it works just how I think it should.

How might I do what I want in this case? (I'm looking to eventually bind this to a leader key sequence.)

Thanks!

1 Comment
2021/06/10
03:03 UTC

1

Records jumps made with counsel-imenu

I use counsel-imenu a lot to jump around my python scripts, unfortunately when I press C-o to return to my previous position, it works as if I have never changed position using counsel-imenu, how can I tell evil-mode to record jumps made with counsel-imenu?

0 Comments
2021/04/15
17:22 UTC

4

What is Evil's equivalent of Vim's ctrl-g?

As you all likely know, ctrl-g in Vim (in its plainest form) does the following:

  • prints the current file name
  • the cursor position
  • the file status

I haven't figured out what the Evil equivalent is, and searching for ctrl-g finds all sorts of stuff about doom/escape() and Emacs undo. Does anyone know?

Thanks!

6 Comments
2021/03/22
21:08 UTC

2

Trying to map SPC in Evil mode, failing

I had the bright(?) idea to make use of SPC in Evil normal mode to toggle between the display of relative line numbers and absolute line numbers. (Note that I don't use SPC as my leader character: I use comma.)

Here's what I did, and I feel like it's really close since if I execute M-x toggle-relative-absolute-line-numbers it does what I expect:

;;
;; Toggle line numbers between relative and absolute
;; 
(defun toggle-relative-absolute-line-numbers ()
    (interactive)
    (if (string-equal display-line-numbers "t")
        (setq display-line-numbers 'relative)
        (setq display-line-numbers 't)))

(define-key evil-normal-state-map (kbd " ") 'toggle-relative-absolute-line-numbers)

What did I do wrong?

Thanks for any pointers!

3 Comments
2021/03/13
18:27 UTC

8

Orgmode: Automatically enter Insert mode when creating a new heading or list item.

When creating a new heading or list item with Alt-Enter it seems only natural that Evil should be in Insert mode, much how o and O add a line and leave the user in Insert mode.

How can this be configured? I'm on Emacs 26.3, Kubuntu 20.04.

7 Comments
2021/01/05
16:39 UTC

3

prevent "C" from putting things to kill ring

Hi,

In evil-mode, I often copy some string from web and want to replace something in my doc. So I press "C" to replace to the end of line. However, this just overwrites the first copy I did. Is there any better way to do this?

Thanks

3 Comments
2020/12/18
19:52 UTC

7

Long-time Emacs user looking to get started with evil-mode

Hi there!

I'm a long-time Emacs user, so the default keystrokes are hardwired into my muscles. Unfortunately, some of those muscles have decided they don't like the keystrokes, and I've been suffering from a little RSI, so I'm giving evil-mode a spin to see if that will help.

Is there a cheat sheet or anything that maps common Emacs commands (e.g. `C-x b`) to the evil equivalents?

13 Comments
2020/09/03
23:01 UTC

4

How do I move columns of text?

I use Emacs and Evil.

I had a problem today editing a Markdown file.

The Markdown file had data like this:

foo
bar
blah

42
212
71

test result
some other problem
unable to find

What I wanted to end up with was this, where the \t represents a tab character:

foo\t42\ttest result
bar\t212\tsome other problem
blah\t71\tunable to find

I messed around with visual blocks (from Evil's Vim emulation) and tried some Emacs rectangle commands; either I totally misunderstood how to use them or they just don't do what I wanted (I kept ending up with jumbled up data).

I also considered using the Unix paste(1) command, but I ultimately punted, pasting each of the three columns into a spreadsheet, copying the columns from the spreadsheet and then pasting them back into Emacs. From there I was able to format the data as a Markdown table.

What was the right Emacs/Evil way to have done this? (Heck, I'd even settle for the right way to have done this in plain old Vim.)

Thanks!

7 Comments
2020/08/18
23:47 UTC

5

An :ex command surprise

I've just started using Emacs and Evil (via Doom), coming from vim.

Recently I ran into a situation where I had a list of items like this:

foo bar blah

which I wanted to turn into this:

foo
bar
blah

In vim, I would have done something like this (where ^V and ^M are C-v and C-m, not literals):

:s/ /^V^M/g

That did not work in Evil.

I experimented with a variety of things that did not work until I eventually stumbled on this:

:s/ /^Q^J/

Note the lack of the g global flag on that :ex command, which surprised me.

Are there similar gotchas that I should know about? (Other suggestions on how I should have done this are also welcome.)

Thanks!

6 Comments
2020/07/05
15:50 UTC

5

Evil-mode and magit

I'm an old vim user, finally decided to try evil today.

I've installed magit, and it works, but I'm finding myself having to do C-x g to get to the magit-status, and I don't want to use control-keys regularly. What's a sane vim-style binding to use here?

I've seen there's an evil-magit package, does anyone here use it?

5 Comments
2020/03/22
13:34 UTC

3

How to Configure Cursor Shape?

I'm using evil and have attempted to configure the cursor shape to be a horizontal bar as shared below. All modes except insert mode take the configured shape of a horizontal bar. Does anyone know how to resolve this behavior so all modes use the horizontal bar?

;; Set cursor type
(setq-default cursor-type 'hbar)
;; Enable evil
(use-package evil
  :ensure t
  :init
  (evil-mode t)
  :config
  (evil-set-initial-state 'term-mode 'emacs)
  (setq evil-default-cursor 'hbar
        evil-emacs-state-cursor 'hbar
        evil-normal-state-cursor 'hbar
        evil-motion-state-cursor 'hbar
        evil-visual-state-cursor 'hbar
        evil-insert-state-cursor 'hbar
        evil-replace-state-cursor 'hbar
        evil-operator-state-cursor 'hbar)
  (define-key evil-normal-state-map (kbd "C-d") 'evil-scroll-down)
  (define-key evil-visual-state-map (kbd "C-d") 'evil-scroll-down)
  (define-key evil-normal-state-map (kbd "C-u") 'evil-scroll-up)
  (define-key evil-visual-state-map (kbd "C-u") 'evil-scroll-up)
  (define-key evil-insert-state-map (kbd "C-u")
    (lambda ()
      (interactive)
      (evil-delete (point-at-bol) (point)))))
0 Comments
2020/03/18
01:15 UTC

1

How to get line numebr from evil-visual-beginning

I want to know the line number of the beginning of my current visual selection. The variable evil-visual-beginning contains a marker that marks the beginning of the current visual selection. Is there a way to extract the line number from it, or is there even an easier way apart from using this variable?

1 Comment
2020/01/26
17:09 UTC

3

Preview substitution/replace

I want to make the switch to emacs with evil and currently I am struggling to get a preview on the substituions/prelaces. In neovim I can do it with `set inccommand=nosplit`. Spacemacs can do that too, but I can not find the code in the spacemacs configs that does that. Google did not helped either. Can you help me out here?

I thought this was the appropiate subreddit for this question since I am actually using evil mode.

2 Comments
2019/01/26
21:56 UTC

2

Regex Capture Groups In Evil

0 Comments
2018/10/03
03:13 UTC

2

Confusion with using Vim style 'Very Magic' or \V in evil mode

Greetings all,

I've just got a small question. In my emacs init stuff I have the following lines for my evil config:

  (evil-select-search-module 'evil-search-module 'evil-search)
  (setq evil-magic 'very-magic)

However, when I try to use / to search or :%s/ to search and replace, both continue to treat symbols like ( as character literals rather than the 'special' meaning I anticipate. Additionally, when I try to do /\V or :%s/\V both treat the \V as a literal 'V'.

Thanks in advance for your help

0 Comments
2018/09/29
17:31 UTC

Back To Top