How can I quickly quote/unquote words and change quoting (e.g. from ' to ") in Vim? I know about the surround.vim plugin, but I would like to use just Vim.
How can I quickly quote/unquote words and change quoting (e.g. from ‘ to )
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
surround.vim is going to be your easiest answer. If you are truly set against using it, here are some examples for what you can do. Not necessarily the most efficient, but that’s why surround.vim was written.
ciw'Ctrl+r"'ciw– Delete the word the cursor is on, and end up in insert mode.'– add the first quote.Ctrl+r"– Insert the contents of the"register, aka the last yank/delete.'– add the closing quote.di'hPl2xdi'– Delete the word enclosed by single quotes.hP– Move the cursor left one place (on top of the opening quote) and put the just deleted text before the quote.l– Move the cursor right one place (on top of the opening quote).2x– Delete the two quotes.va':s/\%V'\%V/"/gva'– Visually select the quoted word and the quotes.:s/– Start a replacement.\%V'\%V– Only match single quotes that are within the visually selected region./"/g– Replace them all with double quotes.