Indentation in Atom/VS Code

Both of the editors render the following 3 lines, of which 2 are continuation of the first, without any indentation. That is,
like this:

fcoarsetransferred = transferfield!(fcoarsetransferred, 
fensfine, regionsfine[i]["femm"].geod.fes, fcoarse,
fcoarse, fenscoarse, regionscoarse[i]["femm"].geod.fes, geometricaltolerance)

What I would like of course is

fcoarsetransferred = transferfield!(fcoarsetransferred, 
        fensfine, regionsfine[i]["femm"].geod.fes, fcoarse,
        fcoarse, fenscoarse, regionscoarse[i]["femm"].geod.fes, geometricaltolerance)

Has anyone else had this experience? If so, and if it isn’t just me, are there any fixes?

1 Like

Yes, I also experienced this in atom. Don’t know the solution of how to do it in atom, but in vim you can add this to your .vimrc file

set linebreak breakindent breakindentopt=shift:2

where the shift parameter determines how far you want to indent.

2 Likes

Thanks, that is good to know. I’ve always liked vim. However, the Atom and VS code editors are really convenient to work with, and I would really like to see the indentation improved.

In the settings for Atom’s language-julia package is a Soft Wrap option that is switched off by default. After activating it and setting the Soft Wrap Hanging Indent to 8, you get the desired indention:

In VS Code indented wrapping can be activated by adding

    "editor.wordWrap": "on",
    "editor.wrappingIndent": "indent",

to your User Settings.

Thanks for your suggestions. I’ve tried so far with VS code, but unsuccessfully: I still get

        modeldata = FDataDict("fens"=>fens,
        "regions"=>regions,
        "essential_bcs"=>[ex, ey, ez],
        "traction_bcs"=> [Trac]
        )

when I do re-indent on this block of code.
This is what my “user settings” look like. I hope that this is what you had in mind?

{
    "julia.executablePath": "C:\\Users\\PetrKrysl\\AppData\\Local\\Julia-0.6.0\\bin\\julia.exe",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "workbench.colorTheme": "Tomorrow Night Blue",
    "julia.runlinter": false,
    "window.zoomLevel": 0,
    // When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
    "editor.detectIndentation": false,
    // Controls if the editor should automatically adjust the indentation when users type, paste or move lines. Indentation rules of the language must be available. 
    "editor.autoIndent": true,
    "editor.wordWrap": "on",
    "editor.wrappingIndent": "indent",
}

Actually, I did not find the soft-wrap setting in the Julia settings. I did find it in the editor settings:


Setting it however did not work. Still the same behavior.

I am on 1.21.1, Windows 10.

For Julia files the editor settings are overwritten by the language-julia settings. The following picture shows where they can be found:

Okay, found the soft wrap in the language-Julia settings. The settings you suggested are on, still no correct indentation.

Which version of the package do you have installed?

I am on language-Julia 0.12.0…

It seems to work fine for me on my end in atom.

I will try to reinstall everything. Oh well…

Did you enable soft wrap?

Yes, I did. Both for the editor settings and for language-Julia.

Okay. With Atom reinstall from a clean slate the soft wrap works. I will try to install the packages that I used to use to see which one breaks it.

Thanks all for your help. By the way, if you have a solution for VS code please don’t hesitate to let me know.

With clean install of VS code I can get the soft wrap to work. Thanks!