/r/evilmode
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.
/r/evilmode
In emacs, you can navigate to the next page (^L or form-feed) using C-x ]. I am wondering if evil has a more convenient shortcut for that?
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.
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.
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
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. : )
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
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?
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.
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?
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?
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
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)
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!
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'
.
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?
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!
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?
As you all likely know, ctrl-g
in Vim (in its plainest form) does the following:
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!
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!
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.
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
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?
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!
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!
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?
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)))))
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?
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.