Skip to content

Commit 91177db

Browse files
Merge pull request #3 from asb3993/amburns-editorconfig
Adding editorconfig content
2 parents ae12323 + 3133576 commit 91177db

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

mac/editorconfig.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ ms.assetid: 26A0DE31-2FBF-4E1B-99FB-083111AA1680
1111

1212
# Creating and editing a custom EditorConfig file
1313

14-
In Visual Studio for Mac, you can add an [EditorConfig](http://editorconfig.org/) file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase. The settings declared in the EditorConfig file take precedence over global Visual Studio text editor settings. Using EditorConfig within your project or codebase allows you to set your coding style, preferences, and warnings for your project. This makes it easier for all Visual Studio for Mac users to adhere to the coding practices of a project.
14+
In Visual Studio for Mac, you can add an [EditorConfig](http://editorconfig.org/) file to your project or solution to enforce consistent coding styles for everyone that works in the codebase. The settings declared in the EditorConfig file take precedence over global Visual Studio for Mac text editor settings. Using an EditorConfig file within your project or codebase allows you to set your coding style, preferences, and warnings for your project. Because the file is part of your codebase, it makes it easier for all users to adhere to the coding practices of a project, regardless of the IDE or code editor that they use.
1515

1616
[EditorConfig](http://editorconfig.org/) files are supported on many IDEs and code editors, including Visual Studio 2017.
1717

1818
## Supported settings
1919

20-
The editor in Visual Studio supports the core set of [EditorConfig properties](http://editorconfig.org/#supported-properties):
20+
The editor in Visual Studio for Mac supports the core set of [EditorConfig properties](http://editorconfig.org/#supported-properties):
2121

2222
- `indent_style`
2323
- `indent_size`
@@ -28,20 +28,26 @@ The editor in Visual Studio supports the core set of [EditorConfig properties](h
2828
- `insert_final_newline`
2929
- `root`
3030

31-
EditorConfig also supports [Code style formatting](https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference) in C#.
31+
EditorConfig also supports [Coding conventions](https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference) in C#.
3232

3333
## Add an EditorConfig file to a project
3434

3535
### Adding a new EditorConfig file
3636

37-
1. Open your project in Visual Studio for Mac. Select the project node that you wish to add files to.
37+
1. Open your project in Visual Studio for Mac. Select either the solution or project node that you wish to add the EditorConfig file to. Adding the file to the solution directory applies the .editorconfig settings to all projects in the solution.
3838

39-
2. With the project node selected, go to **File > New File…** in the menu bar to open the **New File** dialog.
39+
2. Right-click on the node and select **Add > New File…** to open the **New File** dialog:
40+
41+
![Content menu items](media/editorconfig-image0.png)
4042

4143
3. Choose **Misc > Empty Text File** and give it the **Name** `.editorconfig`. Press **New** to create the file and open it in the editor:
4244

4345
![New file dialog](media/editorconfig-image1.png)
4446

47+
Adding the item at the solution level automatically creates and nests it in a **Solution Items** folder:
48+
49+
![Solution item displayed in solution pad](media/editorconfig-image1a.png)
50+
4551
4. Edit the file. For example:
4652

4753
```EditorConfig
@@ -59,29 +65,41 @@ EditorConfig also supports [Code style formatting](https://docs.microsoft.com/vi
5965
csharp_new_line_before_open_brace = none
6066
```
6167
62-
4. Adding the file does not automatically update your settings. To reflect the settings from the `.editorconfig` file, select the project node and choose **Edit > Format > Format Document** from the menu bar:
68+
4. While adding the automatically update your settings for any new code that you add, existing code will need to be reformatted. To reflect the settings from the `.editorconfig` file, select the project node and choose **Edit > Format > Format Document** from the menu bar:
6369
6470
![Format Document menu item](media/editorconfig-image2.png)
6571
6672
### Adding an existing EditorConfig file
6773
6874
If you're working with a project or solution that already contains an `.editorconfig` file, there is nothing that you need to do to apply the settings. Any new lines of code are formatted according to the EditorConfig settings. You should note that while Visual Studio for Mac will respect `.editorconfig` files at the solution level, they might not appear in the solution pad due to the fact the files beginning with `.` are hidden files in macOS.
6975
70-
You may want to reuse an existing `.editorconfig` file in your project. To add an existing file, you first need to display hidden files in Finder by entering the following command in **Terminal**:
76+
You may want to reuse an existing `.editorconfig` file in your project. To add an existing file, do the following:
7177
72-
```bash
73-
$ defaults write com.apple.Finder AppleShowAllFiles true
74-
$ killall Finder
75-
```
78+
1. Right-click on the folder you wish to add it to and select **Add > Add Files…**.
79+
80+
2. Browse to the directory of the required file.
81+
82+
3. Files beginning with `.` (such as `.editorconfig`) are hidden files in macOS, so press **Command + Shift + .** to make the `.editorconfig` file visible.
7683
77-
Once the `.editorconfig` file is visible, drag it to your project node. When you're presented with the following dialog, select the **Copy the file to the directory** option and select **OK**:
84+
4. Select the `.editorconfig` file and click **Open**:
7885
79-
![Format Document menu item](media/editorconfig-image3.png)
86+
![adding a new file window](media/editorconfig-image3b.png)
8087
81-
To reflect the settings from the `.editorconfig` file, select the project node and choose **Edit > Format > Format Document** from the menu bar.
88+
5. When you're presented with the following dialog, select the **Copy the file to the directory** option and select **OK**:
89+
90+
![Add file to folder dialog options](media/editorconfig-image3.png)
91+
92+
### Reflecting .editorconfig settings
93+
94+
Once you add an EditorConfig file to your codebase, any new code added is automatically formatted according to the specified settings. Existing code doesn't automatically reflect the settings unless you format the codebase.
95+
96+
To reflect the settings from the `.editorconfig` file, select the solution node and choose **Edit > Format > Format Document** from the menu bar:
97+
98+
![Format document from the menu bar](media/editorconfig-image3a.png)
8299
83100
## Editing an EditorConfig file
84101
102+
85103
EditorConfig files use a straightforward file layout to specify settings, which is explained below using a previous example:
86104
87105

mac/media/editorconfig-image0.png

57.2 KB
Loading

mac/media/editorconfig-image1a.png

13.4 KB
Loading

mac/media/editorconfig-image3a.png

81.2 KB
Loading

mac/media/editorconfig-image3b.png

57.4 KB
Loading

0 commit comments

Comments
 (0)