Formatting Razor Files in Visual Studio Code

前端 未结 2 935
心在旅途
心在旅途 2020-12-16 11:14

Anyone have a good solution for formatting Razor files inside of VSCode? I\'ve tried making it work with prettify-vscode and beautify. But in both cases it can\'t tell that

2条回答
  •  隐瞒了意图╮
    2020-12-16 11:41

    There is an extension that we can switch between Language Modes by shortcuts quickly: changeLanguageMode.change

    I use these shortcuts for js, html, and cshtml:

     {
        "key":"ctrl+k j", 
        "command":"changeLanguageMode.change", 
        "args": {
            "languageId":"javascript"
        }
    },  
    {
        "key":"ctrl+k h", 
        "command":"changeLanguageMode.change", 
        "args": {
            "languageId":"html"
        }
    },  
    {
        "key":"ctrl+k k", 
        "command":"changeLanguageMode.change", 
        "args": {
            "languageId":"aspnetcorerazor"
        }
    }
    

    To open keybindings.json and add these shortcuts:

    open up the control palette with CTRL +SHIFT + P and select Preferences: Open Keyboard Shortcuts File.

    Then use Ctrl + K, Ctrl + F to Format Selection only.

提交回复
热议问题