Trying to map the NERDCommenter's toggle comment action (mapped to <leader>c<space>) to alt+/, something a bit more familiar. I tried:

nnoremap <A-/> <leader>c<space>

...but it doesn't seem to work or do anything. Do I have the key alt+/ wrong ? how can you represent the / character in .vim ?

  • 1
    Does this answer your question? How to map Alt key? – B Layer Nov 20 '20 at 20:34
  • 1
    I tried what was suggested. The 1st one gives me an error: Error detected while processing /Users/akharrou/.config/nvim/general/settings.vim: line 539: E518: Unknown option: <M-j>=^[j The 3rd answer doesn't say how to represent "/". The 4th answer doesn't work either, it's like nothing happens or I don't get it. The 2nd and last answers don't say how to represent "/" and are irrelevant because I already have "alt" working, just don't know how to combine alt <A- with the character "/"... – Akharrou Nov 20 '20 at 20:59
  • 1
    / is /. It's not the problem. Did you try Insert mode, hit Ctrl-V then hit Alt-/? Whatever you see there make that the mapped key. In one of my environments it's ^[/. The ^[ is the control character equivalent to Esc. So I do nnoremap <Esc>/ etc. That's an example. – B Layer Nov 20 '20 at 21:28
  • I just noticed you said "nvim" in your comment (but not in your question...you should specify that). See :h :map-alt-keys. (It says something similar to my last comment.) ..... (Edit: I added "nvim" tag to your question) – B Layer Nov 20 '20 at 21:40
  • Just tried it, it just doesn't read anything it seems, like nothing is sent through or vim is listening for the wrong key. Because literally no action takes place, I go to insert mode, press ctrl-o, and press alt+/ but nothing takes places, it just keeps waiting for a command. I tried: nnoremap ^[/ <leader>c<space> nnoremap <Esc>/ <leader>c<space> nnoremap <A-/> <leader>c<space> – Akharrou Nov 21 '20 at 8:21

Your Answer

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

Browse other questions tagged or ask your own question.