vim

For discussion on all things (neo)vim.
orestis 2020-08-07T07:46:23.497200Z

I’m tearing my hairs out trying to might <C-right> to do a slurp in insert mode using vim-sexp. I’m trying to use guidance from vim-sexp-mappings-for-regular-people which does:

nmap <buffer> >)  <Plug>(sexp_capture_next_element)

orestis 2020-08-07T07:48:56.498100Z

I got to:

inoremap <buffer> <C-right> <C-o><Plug>(sexp_capture_next_element)
which doesn’t do anything, which is an improvement over previous attempts, but I’m possibly missing something fundamental. I’ve no idea what <Plug>is supposed to mean.

Olical 2020-08-07T10:08:12.499900Z

So &lt;plug&gt; is a sort of meta prefix plugin authors should use for all of their mappings. There is no way to directly press &lt;plug&gt; unlike &lt;leader&gt; etc which can be assigned to a key. I don't think plug can be? Or at least it isn't by default. So the idea is that the mappings exist but they're not mapped to anything you can press, it is then up to you to define your own mappings that press this magical &lt;plug&gt; key combination for you.

Olical 2020-08-07T10:09:01.000400Z

I'm not actually sure if you need to &lt;c-o&gt; there, @orestis :thinking_face: perhaps you've already tried without it though?

Olical 2020-08-07T10:09:32.000800Z

Oh! You should probably use imap, not inoremap!

Olical 2020-08-07T10:10:13.001700Z

The noremap means "ignore any other mappings to avoid infinite loops, just use whatever built in mappings there were", so that means the sexp mapping won't get called, it'll basically do nothing.

Olical 2020-08-07T10:10:57.002600Z

noremap is great if you want to use gf or whatever and you have another plugin that might be overriding it. If however you want to map to some existing mapping from a plugin, you can't use noremap. You want to map to another mapping.

orestis 2020-08-07T10:29:13.003Z

Ah! Thanks

orestis 2020-08-07T10:30:43.004500Z

I also figured out some issue that I had when I used vim-better-default (based on your excellent blogpost) — I had to call

runtime! plugin/default.vim
and then override any settings after that, otherwise a lot of settings were not “taking”, which was madenning.

orestis 2020-08-07T10:33:33.004700Z

Hooray imap &lt;buffer&gt; &lt;C-right&gt; &lt;C-o&gt;&lt;Plug&gt;(sexp_capture_next_element) works

Olical 2020-08-07T11:37:54.004900Z

Woo! 😄

Olical 2020-08-07T11:37:56.005100Z

🎉