35

vi, vip and viper (ordered by creation date) come built-in with Emacs, all of those emulate VI. vim-mode is a newer, stand-alone effort to actually emulate Vim, vimpulse is a set of extras on top of viper to give one the most useful Vim features. evil was created as replacement to vim-mode. evil is the most recent project and the only one that's actively ...


18

Another answer: use M-x picture-mode. You can kill or copy rectangles through the middle of tab chars etc., send them to registers, etc.


16

Compilation Mode does the same thing and is built-in. Here is a demo. Basic usage: M-x compile to run the compilation command (like :make) The command is taken from the variable compile-command (like the makeprg option) M-g p and M-g n to go to the location of the previous/next error (like :cp and :cn) M-{ and M-} to go to the previous/next file with an ...


10

The extend-rectangle-to-end function in the rectangle-utils package is what you want. It's on melpa. It inserts spaces to make the current rectangle selection extend to cover the longest line in the region. To get this behaviour, I've got this in my init.el. C-x r e is not bound to anything else in vanilla emacs (require 'rectangle-utils) (global-set-key ...


9

Since evil is the only actively developed vim emulation mode to my knowledge, I'll make my answer evil-specific. evil is highly usable and very close to a vim-like experience, but there are some vim features that most likely won't be implemented (by design) and some that are incomplete but might be added eventually. Some examples of things that most likely ...


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. ...


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).


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.


5

In general, this is something that you would use narrow-to-region for. You move the cursor (for example, by searching) to the beginning of the region and press C-SPC, then move to the end of the region and type M-x narrow-to-region. Now you can issue any search and replace commands that you want and they will only apply to narrowed part of the buffer. Once ...


5

(This answer is more focused on Spacemacs, so it won't give a general answer about Vim-style mappings in Emacs.) If you define jf in the insert-state map, then you won't be able to insert j any more. Simulating ESC in insert-state by quickly pressing a sequence of keys is a non-trivial task. There are several packages for this, keychord.el is one of them, I ...


4

Taken literally, your sample line would translate to the following: (define-key evil-normal-state-map (kbd "<tab>") (kbd ">>")) Although I don't personally recommend this. It's much cleaner to reference the function you want to run by name instead of using a keyboard macro. This clears up the need for a distinction between nmap and nnoremap, ...


4

Emacs has a different concept than Vim. The "emacs way" is to create functions and bind them, which is generally more flexible and readable than vim's map approach. You can create the command for what you need and bind it: (defun delete-selection-and-paste () (interactive) (delete-region (region-beginning) (region-end)) (yank)) (define-key evil-...


4

If your ~/dotfiles/rundo.sh accepts stdin as input, like many other commands such as grep/wc/bash/python, to run a command with the region as stdin, simply run M-| ~/dotfiles/rundo.sh (M-| runs shell-command-on-region). If the command doesn't support stdin, the following should do what you described (defun rundo (beg end) "Wrapper of ~/dotfiles/rundo.sh."...


4

You would mark the next sexp with C-M-SPC and copy the marked region to the kill-ring with M-w. You might find such questions more appropriate on Emacs.SE.


3

It's not documented well enough, and possibly poorly named, but the hideshow function hs-hide-level will collapse all the blocks within the current block. That is, if your cursor is on the class ... line (or below it) in your example input, it will give you something very similar to your desired output. Since hideshow works with indentation I've found that ...


3

The goal of Evil is to emulate Vim, whereas the goal of Viper is to emulate Vi. Vim-mode and Vimpulse are the predecessors of Evil and to my knowledge not developed anymore. The Evil project was started to address shortcomings of these projects.


3

I'm not sure whether there's an Evil-specific way to do this. However, you can write a short Elisp snippet that does this: (defun my/insert-char (char count) (interactive "c\np") (insert-char char count)) When you map insert-char to a key directly, it will prompt you for the character, which is why I wrapped it in my/insert-char. The function can be ...


2

You can use quarter-plane-mode from the quarter-plane package in GNU ELPA. It aims to provide this kind of functionality. But note that it does it basically by reusing picture-mode's code, so it suffers from the same problem: it will add spaces/lines to your buffer when you move around (and then remove them when you leave the mode), so it will/may make ...


2

Imagine a disclaimer about future predictions usually being flat-out wrong I consider it rather unlikely to happen. The reason one implements Vim in Emacs is to have first-class integration into it. In Evil, you can customize a significant amount of tunables (the most important one being the list of modes per initial state as it makes or breaks your ...


2

After some searching I have figured this out. Evil actually already has the search-forward functionality just like vim. Here is where the mapping to * is defined: https://github.com/emacs-evil/evil/blob/427cf5faa57e8794ac93f594dc3d1972e687a25a/evil-maps.el#L232 However, it appears that spacemacs overrides this mapping: https://github.com/syl20bnr/...


2

Evil-visualstar is a package that provides the feature, but I am not sure of the compatibility with spacemacs.


2

I believe the method given in the question, although not efficient, is sufficient. Let me explain it in greater detail. Assuming you have evil-mode enabled: Toggle hs-minor-mode to enable folding Place your cursor at the first column of a def statement line. This can be done by pressing 0 Record a macro which folds the current section and then moves to ...


1

In the end, I just looked at the evil source and modified some functions to always pass in ?_ (the black hole register). My .emacs looks like this now: (use-package evil :ensure t :config (evil-mode 1) (key-chord-define evil-insert-state-map "jj" 'evil-normal-state) (defun delete-selection-and-paste () (interactive) (delete-region (region-...


1

This is possible using evil-indent and evil-get-marker. This uses the with-undo-collapse macro so the operation doesn't create multiple undo entries. (defun paste-and-indent-after () (interactive) (with-undo-collapse (evil-paste-after 1) (evil-indent (evil-get-marker ?\[) (evil-get-marker ?\])))) (defun paste-and-indent-before () (interactive)...


1

upgrade to evil-matchit 2.1.4 This is a bug in 2.1.3. Setup is not necessary. It works out of box now.


1

Have you tried C-x C-b (list-buffers)? That gives you a list of buffers in another window. It will remain visible, depending on what keys you use to access the listed buffers. ? in that window tells you what keys are available: Buffer Menu mode defined in ‘buff-menu.el’: Major mode for Buffer Menu buffers. The Buffer Menu is invoked by the commands C-x C-b, ...


1

(key-chord-define evil-insert-state-map "jk" 'evil-normal-state) Escape from insert mode You need keychord for that, by the way. You can install it from your package manager.


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