Saturday, September 19, 2020

Re: How to replace string in specific paragraph only?

Hi,
I have come out with one of the possible solution:

" move to first line/character in buffer
gg

" find "XXX", visually select paragraph and replace "aaa" with bb", then move to the next paragraph.
execute "normal! /XXX\<cr>v}:s/aaa/bbb/g\<cr>\<esc>}"

Above command works perfectly for first paragraph. Now I need to execute it many times to the end of buffer. I can manually execute above command many times and it works perfectly.
But, how to execute above "execute" command automatically so many times that it gets to the end of buffer. Why? Because finally, I would like to save the vim commands to file and execute vim commands from file to affect whole buffer (e.g. with :source command).

Regards

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ae768f76-2796-4b63-8cae-4268088511edn%40googlegroups.com.

No comments:

Post a Comment