I started using IDE 2.3 but I noticed the auto format does something I'd like to change if possible. Curly braces are formatted to have the beginning or top brace right at the end of the line of code it is related to. I would like to have the curly brace on the next line down left justified to it's corresponding indentation lining up with the closing brace so that it is easier to see the blocks of code. Is it possible to change the auto format behavior so that it does this, because right now it "fixes" all of my code from the way I like it to the aforementioned placement.
1 Like
Hi @perigalacticon . You can learn how to customize the behavior of the Arduino IDE 2.x Auto Format feature from this tutorial:
https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-customize-auto-formatter
1 Like
This post (Clang setup; where is .clang-format - #10 by sterretje ) has a zipped .clangformat file attached; it has the setting that you want.
You can test your configuration with http://clang-format-configurator.site/ ; I haven't played much with it.
Hi @sterretje . I think the attachment went missing from your post.
dougp
February 11, 2024, 4:34am
5
FYI, the link at the bottom of that page is dead - for me.
https://docs.arduino.cc/software/ide-v2/
Thanks, fixed
I wanted to link the post so @perigalacticon can follow the discussion.
Thanks for bringing this to our attention @dougp ! I have submitted a fix for the broken link:
arduino:main ← per1234:fix-ide-2_x-links
opened 09:55AM - 12 Feb 24 UTC
The URL of the parent page for the Arduino IDE 2.x documentation was changed fro… m [`/software/ide-v2/`](https://docs.arduino.cc/software/ide-v2/) to [`/software/ide/#ide-v2`](https://docs.arduino.cc/software/ide/#ide-v2) through a recent reorganization of the documentation website.
A redirect was set up, but it did not work for these particular links due to them having a trailing slash, which caused them to lead to the "Oops! There's nothing here" page.
## What This PR Changes
Update the broken links to point directly to the new URL of the target page.
## Contribution Guidelines
- [x] I confirm that I have read the [contribution guidelines](https://github.com/arduino/docs-content/tree/main/contribution-templates) and comply with them.
1 Like
opened 06:58PM - 09 Oct 22 UTC
topic: code
os: windows
type: imperfection
### Describe the problem
The formatting style produced by the Arduino IDE "**… Auto Format**" feature can be customized by the user. This customization can be done either on a per-sketch basis or else globally (https://github.com/arduino/arduino-ide/pull/1019). The global configuration file can be placed in either of two locations:
- Configuration folder (e.g., `C:\Users\per\.arduinoIDE\.clang-format`)
- Data folder (e.g., `C:\Users\per\AppData\Local\Arduino15\.clang-format`)
🐛 If Arduino IDE is started from a path on a different drive than the one containing the global formatter configuration file, the file does not take effect.
### To reproduce
#### Equipment
Extra drive (type and capacity don't matter).
#### Steps
1. Select **File > Quit** from the Arduino IDE menus if it is running.
1. Create a file at the following path:
```text
C:\Users\per\.arduinoIDE\.clang-format
```
with the following content:
```yaml
IndentWidth: 8
```
1. Open a command line terminal on a drive other than `C:\`.
1. Start Arduino IDE from the command line terminal.
**ⓘ** The command line was only used as a convenient way to start the IDE from a different drive. The bug also occurs if the IDE is installed to a different drive and started normally.
1. Wait for the IDE to finish starting up.
1. Select **File > New** from the Arduino IDE menus.
1. Select **Edit > Auto Format** from the Arduino IDE menus.
🐛 The indentation is not changed to 8 spaces according to the global formatter configuration.
### Expected behavior
Global formatter configuration files are recognized regardless of which drive the IDE was started from.
### Arduino IDE version
2.0.1-snapshot-bc264d1
### Operating system
Windows
### Operating system version
10
### Additional context
The cause of the bug is the redundant URI to filesystem path conversion applied to the global configuration file paths:
https://github.com/arduino/arduino-ide/blob/bc264d1adfd525778c45a0fc1414efc51d8eccff/arduino-ide-extension/src/node/clang-formatter.ts#L84
https://github.com/arduino/arduino-ide/blob/bc264d1adfd525778c45a0fc1414efc51d8eccff/arduino-ide-extension/src/node/clang-formatter.ts#L89
https://github.com/arduino/arduino-ide/blob/bc264d1adfd525778c45a0fc1414efc51d8eccff/arduino-ide-extension/src/node/clang-formatter.ts#L95
This causes the paths to have this form:
- `\Users\per\.arduinoIDE\.clang-format`
- `\Users\per\AppData\Local\Arduino15\.clang-format`
That points to the correct place when the IDE is started from `C:\`, but not when it is started from another drive.
The local configuration file path is only subject to a single URI to filesystem path conversion, so it is formatted correctly, meaning the bug does not affect this configuration method:
- `C:\Users\per\Documents\Arduino\sketch_oct9a\.clang-format`
---
Originally reported by @Willem43T at https://forum.arduino.cc/t/clang-setup-where-is-clang-format/1016866/17
### Issue checklist
- [X] I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the problem still occurs when using the latest [nightly build](https://github.com/arduino/arduino-ide#nightly-builds)
- [X] My report contains all necessary details
shows setting for the .clang-format file that will change auto format spaces
IndentWidth: 8
system
Closed
September 6, 2024, 3:24am
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.