How do I make all the docstring using triple double quotes instead of triple single quotes?
<p>I have a long source code in python, and many functions are documented with <code>'''xxx'''</code>, How do I replace them with <code>"""xxx"""</code> quickly? in any text editor ?  pycharm / sublime </p>

<pre><code>def my_func():
    '''
    yeah a doc string
    '''
    pass
</code></pre>

<p>desired result:</p>

<pre><code>def my_func():
    """
    yeah a doc string
    """
    pass
</code></pre>

<p>edit:
Found the solution in pycharm ( or every other text editor)
search for 
<code>'''(\n.*\n\s*)'''\n</code>
and replace with
<code>"""$1"""\n</code></p>

<p>ps: I can not just do a simple search for <code>'''</code>,and replace it with <code>"""</code>, because in the code multi line strings are everywhere, not just in the docstring.</p>

<p>You can achieve it by three methods,</p>

<h3>Method 1: Inspect whole project</h3>

<p>Go to <code>Code &gt; Inspect Code</code>. PyCharm will scan your code (this may take some time) and will show you the inspection results.</p>

<p>In the inspection results, under Python It will show <code>Single Quoted docstrings</code>
<a href="http://i.stack.imgur.com/FDA0d.png" rel="nofollow"><img src="http://i.stack.imgur.com/FDA0d.png" alt="enter image description here"></a></p>

<ol>
<li><p><strong>To change all the files at once</strong> <br>
Select <code>Single quoted docstring</code> from the left pane and click <code>Convert docstring to the triple double quoted string form</code>. Now all the files will be changed to triple double quotes.</p></li>
<li><p><strong>To change for individual files</strong> <br>
Select individual files under <code>Single quoted docstring</code> and for each file click <code>Convert docstring to the triple double quoted string form</code>.</p></li>
</ol>

<h3>Method 2: Replace Code with <code>Replace in Path</code></h3>

<p>In PyCharm, right click on the project and select <strong><code>Replace in Path</code></strong> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd>.
<a href="http://i.stack.imgur.com/7h93g.png" rel="nofollow"><img src="http://i.stack.imgur.com/7h93g.png" alt="enter image description here"></a>
<a href="http://i.stack.imgur.com/U823M.png" rel="nofollow"><img src="http://i.stack.imgur.com/U823M.png" alt="enter image description here"></a></p>

<p>In the <code>Text to find</code> field, enter <code>'''</code> and in <code>Replace with</code> field, enter <code>"""</code>. click find. PyCharm will scan through the files and ask you whether to replace  single occurrence, or all occurences at once.</p>

<h3>Method 3: Use terminal tools or Python to read lines and replace.</h3>

<p>As others mentioned, this method will do the job.</p>

<blockquote>
  <p><strong>I recommend method 1</strong> Since PyCharm is intelligent, it can change doctrings without changing multi-line strings (if you are using it) which is prone to replacement in other methods.</p>
</blockquote>

python pycharm sublimetext docstring