任何人都可以指向插件的方向或其他方式来格式化评论吗?
我正在使用coffeescript,注释与python(#line,### block ###)相同,尽管javascript注释也直接通过编译器。
答案 0 :(得分:0)
好的,事实证明Edit -> Wrap
保持评论不变 - 完全是新的。
答案 1 :(得分:0)
我没有插件,但我可以提供我编写的python脚本。在“用户输入的注释”(uec)变量中输入您的注释作为字符串,保存并运行。它将格式化一个块引号,其中包含80个字符的英镑符号。如果您需要更短或更长的块报价,那么只需更改80,78和76。
def first2lines(): return str(('#' * 80) + '\n' + '#' + (' ' * 78) + '#') # first two lines
def leftSide(): return '# ' # left side of border
def rightSide(): return ' #' # right side of border
def last2lines(): return str('#' + (' ' * 78) + '#' + '\n' + ('#' * 80)) # last two lines
# user entered comment
uec = "This program will neatly format a programming comment block so that it's surrounded by pound signs (#). It does this by splitting the comment into a list and then concatenating strings each no longer than 76 characters long including the correct amount of right side space padding. "
if len(uec) > 0:
eosm = '<<<EOSM>>>' # end of string marker
comment = uec + ' ' + eosm
wordList = comment.split() # load the comment into a list
tmpString = '' # temporarily holds loaded elements
loadComment = '' # holds the elements that will be printed
counter = 0 # keeps track of the number of elements/words processed
space = 0 # holds right side space padding
last = wordList.index(wordList[-1]) # numerical position of last element
print first2lines()
for word in wordList:
tmpString += word + ' ' # load the string until length is greater than 76
# processes and prints all comment lines except the last one
if len(tmpString.rstrip()) > 76:
tmpList = tmpString.split()
tmpString = tmpList[-1] + ' ' # before popping last element load it for the beginning of the next cycle
tmpList.pop()
for tmp in tmpList:
loadComment += tmp + ' '
loadComment = loadComment.rstrip()
space = 76 - len(loadComment)
print leftSide() + loadComment + (space * ' ') + rightSide()
loadComment = ''
# processes and prints the last comment line
elif len(tmpString.rstrip()) <= 76 and counter == last:
tmpList = tmpString.split()
tmpList.pop()
for tmp in tmpList:
loadComment += tmp + ' '
loadComment = loadComment.rstrip()
space = 76 - len(loadComment)
print leftSide() + loadComment + (space * ' ') + rightSide()
counter += 1
print last2lines()
else:
print first2lines()
print leftSide() + "The length of your comment is zero, it must be at least one character long. " + rightSide()
print last2lines()
答案 2 :(得分:-1)
您可以使用netbeans,它具有自动格式化Alt + Mayus + F