In certain situations Emacs doesn't properly paste text. Apparently this only happens if the current buffer isn't saved and both web-mode and evil-mode are loaded. I was able to reproduce this behavior with the following config:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(require 'evil)
(evil-mode 1)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))


Edit the following file:

function test() {
    console.log('hello world');

Then press the following series of keys:

yGPwywp (Copy the function in front of the cursor, go to the function name, copy it behind the cursor)


function test() {
    console.log('hello world');
function test() {
    console.log('hello world');

Apparently the text has been truncated and is being pasted to the next line. If I remove web-mode (the last two lines) from my config, then everything works as expected:

function ttestest() {
    console.log('hello world');
function test() {
    console.log('hello world');

Here is the output of web-mode-debug:

Loading /usr/share/emacs/site-lisp/site-start.d/autoconf-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/cmake-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/desktop-entry-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/git-init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
test.js has auto save data; consider M-x recover-this-file
 [2 times]
versions: emacs(25.0) web-mode("14.0.8")
vars: engine("none") minor("none") content-type("javascript") file("/home/tbo/test.js")
system: window(nil) config("x86_64-redhat-linux-gnu")
colors: fg(nil) bg(nil)
minor modes: (completion-in-region-mode global-eldoc-mode evil-local-mode evil-mode undo-tree-mode global-undo-tree-mode shell-dirtrack-mode)

Here is the output of list-command-history:

(evil-yank 10 14 (quote exclusive) nil nil)
(evil-yank 1 53 (quote line) nil nil)
  • Any updates on this issue? I am having the same problem, where the last character on my clipboard is ommited, and a line break seems to be prefixed to my clipboard.
    – modulitos
    Dec 17 '17 at 5:53
  • 1
    They apparently fixed it in evil: github.com/emacs-evil/evil/pull/937 But I haven't tested it myself. Feb 3 '18 at 15:52
  • Thanks for the update - I just upgraded my evil mode, and it seems to be working! I think I also had to move away from http://stable.melpa.org/packages/ to http://melpa.org/packages/ for the fix to work.
    – modulitos
    Feb 4 '18 at 0:42
  • How about @ThomasBonk write his comment as an answer and OP accept it, so this question can be marked as answered? Jul 25 '18 at 17:26
  • @DavorCubranic I didn't know I could answer my own question. Thanks! Jul 26 '18 at 18:09

They apparently fixed it in evil: https://github.com/emacs-evil/evil/pull/937 But I haven't tested it myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.