reddit / emacs

Evil - duplicated selected lines mapping

JoseConseco_ · 2022-05-05 18:34
Hi, in nivm I can duplicated selected lines (up or down) with: vim.api.nvim_set_keymap('v', '<S-A-j>', ":'<,'>copy'<-1<Return>gv", {noremap = true, silent = true}) vim.api.nvim_set_keymap('v', '<S-A-k>', ":'<,'>copy'><Return>gv", {noremap = true, silent = true}) using following mapping in doom emacs fails (syntax error), but I'm not sure why: (define-key evil-visual-state-map "\S-\M-j" ":'<,'>copy'<-1") (define-key evil-visual-state-map "\S-\M-k" ":'<,'>copy'>") Executing ":'<,'>copy'<-1" on cmdline on selection seems to work ok (selected lines are duplicated). &#x200B; Here is similar working mapping that duplicates current line and it works ok (in normal mode): (define-key evil-normal-state-map "\S-\M-j" ":.copy.") (define-key evil-normal-state-map "\S-\M-k" ":.copy.-1")
JoseConseco_ · 2022-05-05 19:05
Ok I solved it this way: (define-key evil-visual-state-map "\S-\M-j" "y'>p'[V']") (define-key evil-visual-state-map "\S-\M-k" "yP'[V']") Still would be cool to know, why copy method did not work in first post....