2

If I had a typescript file idented by 4 spaces with some SQL strings idented with 2 spaces.

function ts_query(){
    const sql=`
      SELECT *
        FROM table1
        WHERE field1 IS NULL
          AND field2 IS NOT NULL
    `;
    return sql;
}
function other(x:string){
    if(x=="this"){
        return "that";
    }
}

When I select the SQL part and press tab the conent is reidented

reident

In the picture you can see that Visual Code is not respecting my original ident of that code section.

Is there a way to configure VisualStudioCode to do the same that Notepad++ does (i.e.: respecting the original format simply adding 4 spaces).

My settings.json is:

{
    "workbench.colorTheme": "Default Light+",
    "git.autofetch": true,
    "window.zoomLevel": 0,
    "extensions.ignoreRecommendations": false,
    "git.enableSmartCommit": false,
    "git.promptToSaveFilesBeforeCommit": true,
    "window.titleBarStyle": "custom",
    "breadcrumbs.enabled": true,
    "editor.autoIndent": false
} 

I am using Visual Studio Code v1.28.2 in Windows 8.1

5
  • Open settings with Ctrl + comma, search Editor: Insert spaces settings, then check the box to enable.
    – Biswapriyo
    Jan 16, 2019 at 17:58
  • @Biswapriyo Do you try it? It does not works. I try it right now. Jan 16, 2019 at 19:49
  • I'm using it...... OK, there also other settings. 1. set "editor.tabSize": 4 2. enable "editor.detectIndentation": true 3. enable "editor.autoIndent": true.
    – Biswapriyo
    Jan 16, 2019 at 20:10
  • After you press the tab key the word FROM still only 2 spaces righter than SELECT word?. In the original text FROM is 2 spaces rigther, then when I press tab the FROM word earns 2 more spaces. Jan 16, 2019 at 20:12
  • Oooo... That one. It maybe by-design issue.Notepad++ and VSCode uses different modules for syntax.
    – Biswapriyo
    Jan 16, 2019 at 20:35

0

You must log in to answer this question.

Browse other questions tagged .