简体   繁体   English

我的 Visual Studio Code 扩展未正确显示代码

[英]My Visual Studio Code extension is not showing code properly

Hello guys I am a student and a learner, new to Visual Studio code.大家好,我是一名学生和学习者,是 Visual Studio 代码的新手。 I was working with java Scr ipt and whenever I was trying to save my code by pressing Ctrl+save button it was automatically indenting my code which show problems in my terminal can you please help me out: Here is what i wrote before pressing Ctrl+save:我正在使用 java 脚本,每当我试图通过按 Ctrl+save 按钮保存我的代码时,它会自动缩进我的代码,这会在我的终端中显示问题,请你帮帮我:这是我在按下 Ctrl+ 之前写的节省:

  return ( <
        div className = "App" >
        <h1> Hello World this is my world i am the master of this world you all are my slaves! </h1>
        <FormControl >
        <InputLabel > Email a message... </InputLabel> 
        <Input value = { input }
        onChange = { event => setInput(event.target.value) }/>
        <Button disabled = {!input }
        color = "primary"
        variant = "contained"
        onClick = { sendMessage } > send </Button>  
        </FormControl>

{
  message.map(message => ( 
    <Message text={message}/>
  ))
} 
</div>);
  }  

     

And here what it automatically does after pressing Ctrl+S:按下 Ctrl+S 后它会自动执行以下操作:

    return ( <
    div className = "App" >
    <
    h1 > Hello World this is my world i am the master of this world you all are my slaves! < /h1> <
    FormControl >
    <
    InputLabel > Email a message... < /InputLabel>  <
    Input value = { input }
    onChange = { event => setInput(event.target.value) }
    /> <
    Button disabled = {!input }
    color = "primary"
    variant = "contained"
    onClick = { sendMessage } > send < /Button>   <
    /FormControl>

    {
        message.map(message => ( <
            Message text = { message }
            />
        ))
    } <
    /div>);
}

Because this i am getting problems in my terminal as:因为这是我在终端中遇到的问题:

{
"resource": "/c:/Users/DELL/Desktop/fbmsg/fbmsg/src/App.js",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "'</' expected.",
"source": "ts",
"startLineNumber": 41,
"startColumn": 24,
"endLineNumber": 41,
"endColumn": 24

} }

I'm assuming that you'd like to know how to save your work in VS Code without the automatic formatting.我假设您想知道如何在没有自动格式化的情况下将您的工作保存在 VS Code 中。 If that's the case, there's a keyboard shortcut that saves the file without formatting.如果是这种情况,则有一个键盘快捷键可以保存文件而不进行格式化。

For Mac : Shift+KS对于 Mac :Shift+KS

You can also open your command pallet with Shift+Cmd+P and search there for "Save without formatting" and it should tell you the correct shortcut.您也可以使用 Shift+Cmd+P 打开命令托盘,并在其中搜索“不格式化保存”,它应该会告诉您正确的快捷方式。

You can install Prettier extension from the extension market of VS-Code.您可以从 VS-Code 的扩展市场安装Prettier扩展。 It makes code neat and pretty.它使代码整洁漂亮。

  • You can further read about it here你可以在这里进一步阅读
  • Other day to day VS-Code extensions can be found here其他日常 VS-Code 扩展可以在这里找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM