Skip to main content
5 events
when toggle format what by license comment
Oct 30, 2020 at 11:50 comment added Martin Tournoij Writing commands is kind of how Vim works @Sam, which is probably different from VSCode. You can use nnoremap <C-s> :%s// to map it to control+s, for example. Basically mappings just send the keys you'd type (although you can do some more advanced things as well). To automatically add the /g flag and put the cursor in the correct position you can use :nnoremap <C-s> :%s//g<Left><Left>. You can also add the * beforehand, if you'd like.
Oct 28, 2020 at 13:20 comment added D. Ben Knoble @Sam note that it is stored in the search register (:help quote/) which is accessible via @/--as are most registers. We already have a Q somewhere about mapping :%s//... if I can find it
Oct 28, 2020 at 0:09 comment added Sam Thanks for your answer Martin, I knew about the star * operator to match the next word, but I didn't know that it was saved in the @ variable, interesting. I also didn't know I could use this to ignore the first parameter in :%s//replace. It's pretty great. I guess I would ask you, could you show me how to make a nmap or inoremap so we don't have to write the instruction :%s//replace? I would really appreciate it. I'll edit my question to put more context.
Oct 27, 2020 at 22:11 comment added D. Ben Knoble Thinking alike :)
Oct 27, 2020 at 22:07 history answered Martin Tournoij CC BY-SA 4.0