syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.65k stars 4.89k forks source link

Unable to replace text in visual mode with paste #4685

Closed kubaracek closed 4 years ago

kubaracek commented 8 years ago

Description

When I yank a word and then in visual mode select a text that I want to replace pressing p seems to delete the highlighted text which yanks it and paste it instead of the originally yanked text making it impossible to replace a text.

Update

Seems like osx layer causes this weird behaviour.

Reproduction guide

Highlight a word in visual mode. press y to yank the selection go to a word that you want to replace go to visual mode and select this word press p

Right now the word should be replaced with the yanked text but it's replaced with itself == makes no change to the word.

System Info

     '(
     auto-completion
     better-defaults
     ;; Languages
     emacs-lisp
     ruby
     scala
     markdown
     javascript
     shell-scripts
     yaml
     html
     dockerfile
     ruby-on-rails
     ;; org
     (shell :variables
             shell-default-height 30
             shell-default-position 'bottom)
     ;; spell-checking
     syntax-checking
     ;; version-control
     git
     github
     ;; themes
     themes-megapack
     colors
     ;; system
     osx
     tmux
     ;; chat
     erc
     )
TheBB commented 8 years ago

I can't reproduce this. It works as expected here.

kubaracek commented 8 years ago

Just tried to comment out all my layers and it works. So there must gotta be a one that causes this. Let me debug it

kubaracek commented 8 years ago

Ok debugged it by commenting out my active layers and this is caused by osx layer.

nixmaniack commented 8 years ago

I can confirm this and was surprised with this behaviour and wondered this must be the Vim way and continued using it! :smiling_imp:

nixmaniack commented 8 years ago

I faced this in hybrid style(hybrid state). I think delete-selection-mode would be useful in hybrid-state.

aspett commented 8 years ago

Have been having this issue for ages. Did you find any good way to configure the osx layer to fix the issue?

aspett commented 8 years ago

Actually, just tried disabling the osx layer. Issue is still present for me

Steps I used to reproduce:


     emacs-lisp
     git
     ;; osx
     markdown
     org
     ruby-on-rails
     elixir
     restclient
kubaracek commented 8 years ago

Hi @aspett do you have any layer that uses your system clipboard in emacs? When I copy anything from web/(any other app) then p uses another (emacs) clipboard. Which is what I would except.

I have this simple config defined in dotspacemacs/user-config

(defun pbcopy ()
    (interactive)
    (call-process-region (point) (mark) "pbcopy")
    (setq deactivate-mark t))

  (defun pbpaste ()
    (interactive)
    (call-process-region (point) (if mark-active (mark) (point)) "pbpaste" t t))

  (defun pbcut ()
    (interactive)
    (pbcopy)
    (delete-region (region-beginning) (region-end)))

  (global-set-key (kbd "C-c c") 'pbcopy)
  (global-set-key (kbd "C-c v") 'pbpaste)
  (global-set-key (kbd "C-c x") 'pbcut)

This allows me to copy, paste and cut from/to my system clipboard using C-c c for copy C-c v for paste and C-c x for cut

aspett commented 8 years ago

Heya @JacobJakub. No, I've tried disabling all layers and reverting to a stock config, but no joy. I was expecting that copying to system clipboard would allow me to paste via p. I'd rather not set up special keybinds for pbcopy etc- having system clipboard copy into another register would be an ideal alternative.

idrozd commented 8 years ago

Same issue here

While this is not yet solved, one can use kill-ring (SPC r y) to avoid looking for and copying source of attempted paste second time

Grimi94 commented 7 years ago

I am having the same issue with the osx layer

felipeagc commented 7 years ago

I was having the same issue with spacemacs and my own configuration on Arch Linux. Found this solution here. It worked for me, hope it helps.

braham-snyder commented 7 years ago

this is a duplicate of https://github.com/syl20bnr/spacemacs/issues/3735

FieryCod commented 7 years ago

@felipeagc Thank you so much bro :)

bobdanek commented 5 years ago

I'm having a similar problem that sounds like the same root cause.

If I y something in visual mode, or yank a line while not in visual mode, move elsewhere, delete a word or line (d w or D), then p, the thing that gets pasted is the thing I just deleted, not thing thing I yanked.

System:

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

kubaracek commented 4 years ago

I'm having a similar problem that sounds like the same root cause.

If I y something in visual mode, or yank a line while not in visual mode, move elsewhere, delete a word or line (d w or D), then p, the thing that gets pasted is the thing I just deleted, not thing thing I yanked.

System:

  • OS: macOS 10.14.2 (18C54)
  • SpaceMacs version: 0.200.13@26.1
  • Emacs version: d12frosted/emacs-plus/emacs-plus: stable 26.1 (bottled), devel 26.1-rc1, HEAD

@bobdanek This is a default vim behavior :)) https://vim.fandom.com/wiki/Remembering_previous_deletes/yanks

type :reg to see all the registers