How to continue the map when an error come out?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to continue the map when an error come out?

Zhe Lee
nnoremap <leader>k :%s/\v^\s+//g<CR>:sort u<CR>:xa<CR>


This is my map. When there is no match to the "^\s+", an error will come out, and the map will pause, the sort u, and the xa will not be executed. So how to continue the map when there is an error come out?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to continue the map when an error come out?

Ben Fritz
On Saturday, July 15, 2017 at 10:07:08 AM UTC-5, Zhe Lee wrote:
> nnoremap <leader>k :%s/\v^\s+//g<CR>:sort u<CR>:xa<CR>
>
>
> This is my map. When there is no match to the "^\s+", an error will come out, and the map will pause, the sort u, and the xa will not be executed. So how to continue the map when there is an error come out?

Add the 'e' flag to your substitute command to not throw an error for no matches.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...