reaCodes
V2EX  ›  JetBrains

Pycharm 能不能配置回车换行自动格式化之前的代码,像 Visual Studio 那样

  •  
  •   reaCodes · Oct 22, 2019 · 8634 views
    This topic created in 2420 days ago, the information mentioned may be changed or developed.
    我知道已经有快捷键 Ctrl + Alt +L 自动格式化代码,但是还是不如 Visual Studio 那样每次加上分号结尾就格式化体验连贯好用
    15 replies    2019-10-22 12:16:28 +08:00
    zzWinD
        1
    zzWinD  
       Oct 22, 2019   ❤️ 1
    FileWatcher 里面添加 Black,每天保存文件的时候 自动格式化。挺好用
    https://github.com/psf/black
    sadfQED2
        2
    sadfQED2  
       Oct 22, 2019 via Android   ❤️ 2
    能,可以设置一个宏,我是 ctrl+s 自动格式化
    mcfog
        3
    mcfog  
       Oct 22, 2019 via Android
    宏+1,我也是加保存里的,楼主可以加在回车或者分号上都行
    20015jjw
        4
    20015jjw  
       Oct 22, 2019 via Android
    gg=G Ctrl O
    或者写完 lint
    reaCodes
        5
    reaCodes  
    OP
       Oct 22, 2019
    @mcfog 请问要怎么操作,麻烦提示我一下
    reaCodes
        6
    reaCodes  
    OP
       Oct 22, 2019
    @sadfQED2 主要我还用了自动保存功能
    Tsukihime
        7
    Tsukihime  
       Oct 22, 2019
    @reaCodes Edit - Macros - Start Macro Recording
    qwerthhusn
        8
    qwerthhusn  
       Oct 22, 2019
    python 是不是同样的语句,不同的缩进,逻辑就会不一样,特别像是 if 缩进,然后 if 结束这种。我感觉这种情况下用代码自动格式化不太好
    wizardoz
        9
    wizardoz  
       Oct 22, 2019
    关键是 python 代码能自动格式化吗?
    sadfQED2
        10
    sadfQED2  
       Oct 22, 2019
    @reaCodes #6 无所谓啊,你可以把宏加到分号里面就行了

    @wizardoz #9 python 代码格式化基本上就是冒号前面加个空格,两个变量之间加个空格,不是改变缩进那种
    sadfQED2
        11
    sadfQED2  
       Oct 22, 2019
    @qwerthhusn #8 python 代码格式化基本上就是冒号前面加个空格,两个变量之间加个空格,不是改变缩进那种
    wangchonglie
        12
    wangchonglie  
       Oct 22, 2019
    @sadfQED2 #2 请问怎么设置呀?
    jwk345
        13
    jwk345  
       Oct 22, 2019 via iPhone
    有个 saveactions 的插件,每次保存的时候可以自动格式化
    stanjia
        14
    stanjia  
       Oct 22, 2019
    只是听上去就感觉这个功能很讨厌呢
    Vegetable
        15
    Vegetable  
       Oct 22, 2019
    实际上写起代码来按格式化快捷键都是下意识的,完全没有耽误我。
    反而之前一个同事喜欢自动保存功能,导致经常因为某些软件没开自动保存而丢失工作。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1446 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 16:37 · PVG 00:37 · LAX 09:37 · JFK 12:37
    ♥ Do have faith in what you're doing.