small medium large xlarge

15 Feb 2016, 21:48
Leo (1 post)

Hi Drew,

congratulations on the second edition. I learned a lot from your vimcasts and the first edition of this book; thank you for that.

Playing around with an example from one of the tips I stumbled on something that might be relevant for tip 79 “Escaping Problem Characters”. We want to find the occurrences of the URL in brackets:

Search items: [\\][s] … [s]:\\

Here’s an easier way to do it if ‘incsearch’ is enabled: Place the cursor on the opening bracket [ /h starts selecting the first character of the URL, the h. Ctrl-L (:h c_CTRL-L) will add another character from the current match to the pattern and by holding that chord we can add the entire URL to the pattern. Not only that, as the characters are added, vim will escape them as needed. This is the pattern vim produces (the ‘magic’ option is set): http:\/\/vimdoc\.net\/search?q=\/\\\\

For searching backwards, place cursor on ] ?ht and then Ctrl-L until everything of interest is added to the pattern.

Best regards!

15 Feb 2016, 21:56
Drew Neil (50 posts)

I didn’t know about that. It’s very cool! I’m going to try and incorporate this into my workflow and I’ll see if it’s useful enough to add to a later edition of Practical Vim.

Thanks for sharing! :x

You must be logged in to comment