簡體   English   中英

如何阻止VS代碼強制我使用大括號,否則光標位置變得瘋狂(PHP,或全局應用)

[英]How to stop VS Code forcing me to use braces, otherwise the cursor position goes crazy (PHP, or apply it globally)

VS代碼

if (1 == 1)  // When I hit enter here, the cursor moves to the next line at pos (0)
|
else  
    return; // When I hit enter here, cursor moves to next line/ pos 4
    |       // why is the cursor here? why not pos 0? 

Visual Studio(這就是我想要發生的事情)

if (1 == 1)   // When I hit enter here, the cursor moves to the next line at
    |         // pos 1 if I'm working with Tabs or pos 4 for spaces)

如果你使用這樣的大括號,這在VS Code中不是問題:

if (1 == 1){
    return;
}

但是,我不喜歡在那些場景中使用大括號,如果我不這樣做,VS Code自然會讓我最終編寫這段代碼,這也很糟糕

if (1 == 1)
return;

我試圖在VS Code中獲得相同的行為。 我無法看到為此設置或擴展。 請幫忙。 如果我必須進行擴展,或更新VS代碼源並自行構建,我就是為此,請指出正確的方向。 這很煩人。

您可以創建代碼段。 F1 “usn”=>選擇語言>>

"if": {
    "prefix": "if",
    "body": [
        "if ($1)",
        "\t$2",
        "$3"
    ]
},
"ifelse": {
    "prefix": "ifelse",
    "body": [
        "if ($1)",
        "\t$2",
        "else",
        "\t$3",
        "$4"
    ]
},

以防萬一將其添加到settings.json ctrl + , :

"editor.snippetSuggestions": "top",

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM