[formatting] Autocomplete, auto indent, insert custom snippets
-
I’ve encountered a couple of formatting issues:
- I prefer auto-completion with a two-space indent for braces rather than positioning them at the line’s beginning.
Notepad++ automatically moves braces ({ }) to the beginning of the line. I would like the braces to stay in their original, intended position. For example, I want:
int main() { //code }
But Notepad++ positions them like this:
int main() { //code
-
I would like the tab size to be calculated from the start of the line or the previous tab stop, rather than from where the brace is positioned.
I’ve set the tab size to 3 spaces. When I manually adjust the positions of the braces, Notepad++ automatically adds a tab from the position of the brace, not from the previous tab. -
How can I add or edit code snippets in Notepad++? For example, I want to type “for” and have Notepad++ suggest the “for” loop snippet, then insert the loop template with placeholders that can be navigated using the Tab key.
Thanks.
- I prefer auto-completion with a two-space indent for braces rather than positioning them at the line’s beginning.
-
@abc-def said in [formatting] Autocomplete, auto indent, insert custom snippets:
I’ve encountered a couple of formatting issues:
- I prefer auto-completion with a two-space indent for braces rather than positioning them at the line’s beginning.
Notepad++ automatically moves braces ({ }) to the beginning of the line. I would like the braces to stay in their original, intended position.
Notepad++ offers Basic or Advanced auto-indentation, as described here – neither of those options does “partially”.
You might want to use an external code “pretty printer” for their specific language to enforce certain indentation rules and the like; it’s not “live” as you edit, but it helps with consistency.- I would like the tab size to be calculated from the start of the line or the previous tab stop, rather than from where the brace is positioned.
I’ve set the tab size to 3 spaces. When I manually adjust the positions of the braces, Notepad++ automatically adds a tab from the position of the brace, not from the previous tab.
That’s not my experience.
If I set tabstops to 3, and force an indent on the parens to 3, the next line (in advanced) wants to be 3 more beyond that. And if i backspace to put a semicolon elsewhere (like 1 space right of the braces), then tab after the semicolon, it lines up with the six-space indentation of the comment above and below it.
- How can I add or edit code snippets in Notepad++? For example, I want to type “for” and have Notepad++ suggest the “for” loop snippet, then insert the loop template with placeholders that can be navigated using the Tab key.
The QuickText plugin (available in Plugins Admin menu) does just that. You can even set which key to use for the ReplaceSnip menu command using Shortcut Mapper, which would allow you to set the “complete the snippet” key, which is the same key for “navigate to next hotspot” command. Based on the README, you can set it to TAB without it messing up other Notepad++ tab behavior. I highly recommend this plugin. (And Community regular @Michael-Vincent adopted and maintains it, so questions can be quickly answered.)
- I prefer auto-completion with a two-space indent for braces rather than positioning them at the line’s beginning.
-
It sounds to me like you want an IDE, not a text editor like Notepad++.
There are plugins that allow Notepad++ to work like an IDE, but the core developers of Notepad++ prefer Microsoft Visual Studio to Notepad++ for working on the Notepad++ source code. Make of that what you will.
This has been discussed in other threads at various points, and I can’t be bothered to link here, but the bottom line is that Notepad++ is most suitable for working with data files (e.g., log files, CSV’s, random plaintext notes, INI files, JSON), and most major programming languages (like the C or C++ it appears you are writing) have better productivity tools elsewhere.
-
@Mark-Olson said:
the core developers of Notepad++ prefer Microsoft Visual Studio to Notepad++ for working on the Notepad++ source code. Make of that what you will.
That’s probably because an IDE is wanted for this work, and, as you say, Notepad++ is not the greatest IDE.
and most major programming languages (like the C or C++ it appears you are writing) have better productivity tools elsewhere.
Well, I for one have done pretty well with only Notepad++ for embedded C/C++ work, as well as Python work.