2

As I know, when we cut text using d or c, this text will go to register 1, and shift all registers from 2 -> 9.

I have tested and I see two things:

  1. My text, after cutting, is not going to register 1.
  2. I have tested all other registers using :register but no register contains my text.
  3. I paste text after cutting, but nothing happens (or it just pastes another text when I yank). I think this is obvious because my cut text is gone nowhere in register.

How do I re-config again my vimrc for getting again this normal behavior? Moreover, I have tested both on vim and neo-vim, the problem still persists.

@edit: I tested on vim 7.4, neovim 1.0.4 (all are latest version) on Mac environment. I also tested using short text and long text (text that expanded on multiple lines).

  • Does the issue persist if you start vim as vim -u NONE? Is :nocompatible set? – Wolfie Oct 8 '16 at 22:17
  • @Wolfie the issue doesn't persist when I run vim -u NONE. Look likes something wrong in my config. I have set :nocompatible, I have tried to remove but the problem still be here. – hqt Oct 9 '16 at 2:36
  • I don't understand your problem at all. – romainl Oct 9 '16 at 7:05
  • @romainl my problem is: after I cut a text, I cannot paste it. I have checked and I saw that cut text doesn't go to any register. – hqt Oct 9 '16 at 8:12
  • What text? How large is it? Does it happen always or only in some cases? What Vim version? What environment? Why do you expect your text to go into register 1? Give us a minimum working example if you really want help. – romainl Oct 9 '16 at 8:24
4

It looks like you missed this part in :help quote_number (emphasis mine):

Vim fills these registers with text from yank and delete commands.

Numbered register 0 contains the text from the most recent yank command, unless the command specified another register with ["x].

Numbered register 1 contains the text deleted by the most recent delete or change command, unless the command specified another register or the text is less than one line (the small delete register is used then). An exception is made for the delete operator with these movement commands: %, (, ), `, /, ?, n, N, { and }. Register "1 is always used then (this is Vi compatible). The "- register is used as well if the delete is within a line. Note that these characters may be mapped. E.g. % is mapped by the matchit plugin.

With each successive deletion or change, Vim shifts the previous contents of register 1 into register 2, 2 into 3, and so forth, losing the previous contents of register 9.

  • thanks for pointing me out this important point. I have tested delete text by one line and more than one line, register "1 still not show. Moreover, I tried to check register "- when deleting short text but I don't see data here. – hqt Oct 9 '16 at 10:34
1

Since you said it does not appear under any register with :register, it sounds like it's ending up in "_, the "black-hole register".

If you run :map d and notice that any mappings map d to "_d, you could expand it via :verbose map d and find from where the mapping was set.

Simply append :unmap d past the point in your .vimrc where you source the plugin or file that made the mapping. (This is preferrable to editing said plugin or file, since any upstream changes would undo your edit. Of course, if the setting is in your .vimrc this doesn't apply.)

Additionally, if d (or any other mapping you're having issues with) have multiple mappings (i.e. it's only mapped to "_d for a certain mode), you can delete just that mapping with :[mode]unmap d (e.g. :nunmap d for normal mode, :vunmap d for visual mode or :xunmap d for select mode.

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.