So until now we did not care about whether to use single or double quotes while coding and just picked whatever was closest to our fingertips. All of a sudden a newly issued coding style guide requires the consistent use of single quotes. Even worse our code is written in JavaScript or PHP and we are dealing with inlined HTML, jQuery selectors and regular expressions so we can not simply replace all double quotes with single quotes without the risk of breaking something. Here is how Vim helped my out:

  1. Automatically normalize quotes where it is safe:


  2. Find all lines containing “ but not ‘
  3. Replace all occurences of “ with ‘

  4. Then edit the more complicated situations by hand:


  5. Find all lines containing “ and ‘
  6. For each occurence of “ ask whether to replace it with ‘

Also useful

  1. Create a visual line selection starting at the current line
  2. Replace all occurences of “ inside visual selection with ‘

Useful when using vimdiff

To jump between lines with differences use ]c to jump forward and [c to jump backward. To ignore whitespaces while diffing enter:

:set diffopt+=iwhite