tcomment_vim icon indicating copy to clipboard operation
tcomment_vim copied to clipboard

map TComment_gcc get `E354: Invalid register name: '$'`

Open ruinb0w opened this issue 2 years ago • 3 comments

I maped tcomment like below

vim.keymap.set('n', "<leader>c", '<plug>TComment_gcc')
vim.keymap.set('v', "<leader>c", '<plug>TComment_gc')

The second line works great, but the first one throws the error E354: Invalid register name: '$'

ruinb0w avatar May 09 '23 03:05 ruinb0w

Which version of vim do you use? I still use vim 8.2.

<Plug>TComment_gcc should be something like

 nnoremap <Plug>TComment_gcc :<c-u>call tcomment#ResetOption() \| if 

v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") | set opfunc=TCommentOpFunc_gccg@$

Does this work when defined manually? (You might want to check if the TCommentOpFunc_gcc function exists since I'm not 100% sure.)

tomtom avatar May 09 '23 09:05 tomtom

I tried your code, but still same as before E354: Invalid register name: '$'. My vim is nvim 0.9 by the way, I'm using vim.g.tcomment_opleader1 = '<leader>c'" instead, and it works great.

Screenshot 2023-05-10 at 09 19 54 Screenshot 2023-05-10 at 09 20 36

ghost avatar May 10 '23 01:05 ghost

I don't know nvim so I cannot really help you with that.

Do you really have to escape the pipe character when using the vim.keymap.set() function? I could imagine just the bar "|" with not backslash should work. The backslash is there as a work-around for vim's :map command.

tomtom avatar May 10 '23 07:05 tomtom

Sorry, but I cannot help with nvim.

tomtom avatar Nov 16 '25 14:11 tomtom