I'm doing the following to copy some text inside quotes and paste it in a different place (inside quotes as well):
di"
go-to-buffer-for-copy
copy-string (ex. yi")
then-go-to-prev-buffer
paste-to-string (p)
But I want to do it in a simpler way, like this:
yi"
go-to-buffer-for-paste
replace-inner-quotes-to-yanked-text
s = s. Replace(@"""", @"\"""); In the first example the " has to be escaped with a backslash as it would otherwise end the string. Likewise, in the replacement string \\ is needed to yield a single backslash by escaping the escape character.
You'd use cs'" to change surrounding quotes. Save this answer.
Use the String. replaceAll() method to remove all double quotes from a string, e.g. str. replaceAll('"', '') . The replace() method will return a new string with all double quotes removed.
For "replace-inner-quotes-to-yanked-text" you can use vi"p
.
(pulling my comment into its own answer)
Assuming you use vim
with system clipboard, you could do the following:
"+yi"
to copy the text inside quotes to your system clipboardci"<Ctrl-V><Esc>
replaces what's inside the quotes with the content of your clipboardOne benefit is that if you want to put the original text in multiple places, you can place your cursor in the next position and press .
.
vi"p
, proposed by Randy Morris, works but it replaces the content of your default register and the selection won't be captured in the "do again" command, only the paste.
You could still use the "0
register to access your original text but I haven't found a command that would change inside the quotes and paste in a way that redo maintains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With