This cannot be done in pycharm by default. There is no plugin. You can see the answer in a similar thread
PyCharm line break wrapper comments
,
- - sed awk,
- PyCharm. .
- script, ,
, . , Python, , Python Python Pycharm.
, script ,
import io, re
from textwrap import TextWrapper
import os
current_file = __file__
f = io.open(current_file, 'r')
comment_pattern = re.compile(r"^(\s*)#(.*)")
in_comment = False
def spit_formatted_comments(initial_space, current_comment):
if current_comment:
wrapper = TextWrapper(initial_indent=initial_space + "#",
subsequent_indent=initial_space + "# ")
wrapper.width = 80
data = wrapper.wrap(" ".join(current_comment))
print(os.linesep.join(data))
for line in f:
match = comment_pattern.findall(line)
if match:
if not in_comment:
in_comment = True
current_comment = []
initial_space = match[0][0]
current_comment.append(match[0][1])
elif in_comment:
in_comment = False
spit_formatted_comments(initial_space, current_comment)
current_comment = []
print(line, end='')
else:
print(line, end='')
spit_formatted_comments(initial_space, current_comment)
f.close()
import io, re
from textwrap import TextWrapper
import os
current_file = __file__
f = io.open(current_file, 'r')
comment_pattern = re.compile(r"^(\s*)#(.*)")
in_comment = False
def spit_formatted_comments(initial_space, current_comment):
if current_comment:
wrapper = TextWrapper(initial_indent=initial_space + "#",
subsequent_indent=initial_space + "# ")
wrapper.width = 80
data = wrapper.wrap(" ".join(current_comment))
print(os.linesep.join(data))
for line in f:
match = comment_pattern.findall(line)
if match:
if not in_comment:
in_comment = True
current_comment = []
initial_space = match[0][0]
current_comment.append(match[0][1])
elif in_comment:
in_comment = False
spit_formatted_comments(initial_space, current_comment)
current_comment = []
print(line, end='')
else:
print(line, end='')
spit_formatted_comments(initial_space, current_comment)
f.close()