2

According to the Vim help, using g CTRL-A with visual mode should change several lines in A to that in B:

A:

1.    
1.    
1.    
1.

B:

1.    
2.    
3.    
4.

In my Vim, the CTRL-A is working in normal mode, which increments a number. But when I am using visual mode, whether it is linewise, block or visual, it will not work. For example, when I press CTRL-A in a help file, it will have this error:

E21: Cannot make changes, 'modifiable' is off

But if I use visual mode, there is no such error and no change happens. The same goes for g CTRL-A and for an editable file.

How can I solve this problem? There are no requisites listed on the manual of this feature, so I probably won't need to recompile the Vim again?

EDIT:

  1. E21 is not the real problem, I just want to use it as an indicator that it doesn't work, i.e. it doesn't change or try to change anything.

  2. :ver first line output:

     VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 13 2016 12:09:32)
    

    Included patches: 1-1725

  • IIRC using <C-a> in visual mode was added fairly recently. Which Vim version are you using? – Martin Tournoij Apr 5 '16 at 4:59
  • Just for the record where is the doc saying that g CTRL-A increments numbers in visual mode? My Vim 7.4 :h g_CTRL-A says that it is used to print memory usage statistics for debugging Vim. – statox Apr 5 '16 at 7:27
  • @statox see :h v_g_CTRL-A. I think Carpetsmoker's right and this has to do with the Vim version. On Arch, or with the pi-rho PPA on Ubuntu 14.04, this works, but on Ubuntu 14.04 with the repository Vim (7.4, patches 1-52), it doesn't work. – muru Apr 5 '16 at 7:54
  • @muru Thanks for the link I didn't find the topic because it is not included in my version so I think you and Carpetsmoker are right it must be because OP doesn't have the correct version. – statox Apr 5 '16 at 8:11
  • How can we download such a version of Vim? I have updated mine and it still is not correct. Cloning the git file on github is also not working. – Lepidopterist May 3 '16 at 21:56
-2

Seems like c-a has been mapped to some plugin in your vim. (In that plugin, c-a is mapped to some 'modifiable' action, so that you get that error message....) You might try :vmap to list all key mappings in visual mode and check if there is some plugin or custom key binding who is using c-a.

  • This doesn't account for g<C-a> not working... – Martin Tournoij Apr 5 '16 at 5:45
  • ah....i read the post again, and found out it could be related to 'help files', if you try to 'modify' in that read-only split window, E21 is the error message. Just tried that and got E21, this could be the reason, but it has nothing to do with a normal editable file, just provide more clues here. – Philia Fan Apr 5 '16 at 5:53
  • 1
    Actually not only help buffer are affected by the modifiable setting: The user can use set nomodifiable to other buffers if he wishes. See :h 'modifiable' – statox Apr 5 '16 at 7:32
  • Actually, E21 is not the problem, I just want to use it as an indicator that it doesn't work, i.e. it doesn't change or try to change anything. – Chromium May 4 '16 at 3:21

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.