1

When adding a new pair of eruby tag like <%= %> surrounding Time.now, just type below keys:

yss=

It does the job <%= *Time.now %>. I have no idea how to do the opposite by removing it without using 'undo'.

Here it is probably the fix, but how to use it?

2

Put the following in your ~/.vim/after/ftplugin/eruby.vim file:

nmap <buffer> ds= ds<ds%dw

The idea is we delete each surrounding in turn. First < then %. Next we remove the = and the extra space.

  • I created a new file erb.vim as you mentioned, then open an erb file, tried ds=, it didn't work. What might be wrong? – canoe Jun 7 '15 at 0:17
  • @canoe There are 2 problems. 1) I had a typo in the mapping, It should be nmap instead of nnmap. 2) The 'filetype' for *.erb files is eruby not erb. So you will need to name your file: ~/.vim/after/ftplugin/eruby.vim – Peter Rincker Jun 8 '15 at 14:58
  • Would this mapping be better to use nnoremap instead? It's my understanding set up mappings this way to make sure they don't create recursive issues. In this case, I doubt it will be used elsewhere and it's good to be aware anyway. – Shadoath Jul 31 '18 at 16:09
  • @Shadoath, you are correct nnoremap would be preferred method. However, we are relying on surround.vim to do the ds< and ds%, so using nmap makes this easy – Peter Rincker Jul 31 '18 at 16:58

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.