"} else {" as a new section
-
I’m building an if statement in PowerShell like this:
if (blabla) { } else { }If I do it like this, it does recognize different sections:
if (blabla) { } else { }screenshot:

The problem is that Notepad++ sees it as one block, so I can’t collapse and expand the if and else separately.
Can I adjust this somewhere in Notepad++?Regards,
Bert -
@Bert-Nieuwenampsen said in "} else {" as a new section:
Can I adjust this somewhere in Notepad++?
Notepad++ uses the Lexilla IP by Scintilla for syntax highlighting and folding. Apparently, the PowerShell lexer has a property called
fold.at.else, but Notepad++ doesn’t currently set that option. If Notepad++ were to set that true on PowerShell documents (by setting that property insetPowerShellLexer()), then it would allow folding at} else {for PowerShell.So if someone (you) were to follow the instructions in our Feature Request FAQ, and make an official request, it could be turned on, or a preference could be added to allow the user to toggle it. Then, if the developer thought it was a good idea, it might eventually be added to Notepad++.
Until that happens, you could use the PythonScript plugin to toggle that setting:

vs

To be able to automatically do that, you could edit (or create) your user
startup.pyto includefrom Npp import editor, notepad, LANGTYPE, NOTIFICATION def cb_pwshFoldAtElse(args): if notepad.getCurrentLang() == LANGTYPE.POWERSHELL: editor.setProperty("fold.at.else", 1) notepad.callback(cb_pwshFoldAtElse, [NOTIFICATION.BUFFERACTIVATED])(For more on PythonScript and the user
startup.py, and the need to set ATSTARTUP instead of LAZY for my instructions to work, see our FAQ: How to install and run a script in PythonScript)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login