2014-10-20 76 views
0

當使用鍵盤快捷鍵評論一行時,是否可以改變PyCharm添加散列#的方式? (默認CTRL + /是否可以自定義如何通過鍵盤快捷鍵插入評論?

我想要#是在第1列,而不是在縮進級別。此外,光標在鍵盤快捷鍵後向下移動一行,我寧願將它保留在同一行上。

目前:

def foo(): 
    my_uncommented_line 
    # commented_with_keyboard_shortcut 
    var = "and now the cursor is at the start of this line" 

我想什麼:

def foo(): 
    my_uncommented_line 
# commented_with_keyboard_shortcut 
    var = "cursor stays on the previous line" 

目前,我正在尋找周圍的東西做這個JetBrains的插件回購,但這樣沒有運氣爲止。

我知道這不符合PEP8。我希望能夠使這種變化讓我能與項目的其餘部分保持一致:

Some other good reasons to ignore a particular guideline: 

2. To be consistent with surrounding code that also breaks [the guideline]. 
+1

的評論類似的鍵盤快捷鍵是'CTRL + /'。你確定你不是在談論代碼重新格式化('CTRL + ALT + L')嗎?您也可能想看看[內嵌評論](http://legacy.python.org/dev/peps/pep-0008/#inline-comments)上的pep-8指南,這是您在演示你的代碼示例。 – 2014-10-20 06:56:39

+1

從PEP-8開始:'塊註釋通常適用於跟隨它們的一些(或全部)代碼,並且縮進到與該代碼相同的級別。塊註釋的每一行都以#和單個空格開始(除非它在註釋內縮進文本)。你爲什麼想這樣做? – IanAuld 2014-10-20 07:00:37

+1

@IanAuld:我正在開發一個使用此模式的項目,而不是遵循PEP8,我們希望與其他代碼庫保持一致。 – dthor 2014-10-20 08:34:20

回答

0

你能做的最重要的是改變風格:

enter image description here