blob: 692378928bcaca7d6d2822c451ef2be391994cae [file] [log] [blame] [view]
chaopengba312ce2017-02-12 03:38:251# Use Visual Studio Code on Chromium code base
2
chaopengca285112017-03-02 15:39:043[TOC]
4
chaopengba312ce2017-02-12 03:38:255[Visual Studio Code](http://code.visualstudio.com/)
6([Wikipedia](https://en.wikipedia.org/wiki/Visual_Studio_Code)) is a
7multi-platform code editor that is itself based on Electron which is based on
8Chromium. Visual Studio Code has a growing community and base of installable
9extensions and themes. It works without too much setup.
10
11## Install extensions
12
chaopengca285112017-03-02 15:39:0413`ctrl+p` paste `ext install cpptools you-complete-me clang-format` then enter.
chaopengba312ce2017-02-12 03:38:2514For more extensions: https://marketplace.visualstudio.com/search?target=vscode
15
16Highly recommend you also install your favorite keymap.
17
18An Example to install eclipse keymaps `ext install vscode-eclipse-keybindings`.
19You can search keymaps here.
20https://marketplace.visualstudio.com/search?target=vscode&category=Keymaps
21
22
23## Settings
24
25Open Settings `File/Code - Preferences - Settings` and add the following
26settings.
27
28```
29{
30 "editor.tabSize": 2,
31 "editor.rulers": [80],
chaopengba312ce2017-02-12 03:38:2532 // Exclude
33 "files.exclude": {
34 "**/.git": true,
35 "**/.svn": true,
36 "**/.hg": true,
37 "**/.DS_Store": true,
38 "**/out": true
39 },
40 // YCM
41 "ycmd.path": "<your_ycmd_path>",
42 "ycmd.global_extra_config":
43 "<your_chromium_path>/src/tools/vim/chromium.ycm_extra_conf.py",
44 "ycmd.confirm_extra_conf": false,
chaopengca285112017-03-02 15:39:0445 "ycmd.use_imprecise_get_type": true,
46 // clang-format
chaopeng6fca2b02017-03-03 19:10:5147 "clang-format.executable": "<your_depot_tools>/clang-format",
48 "clang-format.style": "file"
chaopengba312ce2017-02-12 03:38:2549}
50```
51
52### Install auto-completion engine(ycmd)
53
54```
55$ git clone https://github.com/Valloric/ycmd.git ~/.ycmd
56$ cd ~/.ycmd
57$ ./build.py --clang-completer
58```
59
60## Work flow
61
621. `ctrl+p` open file.
chaopengca285112017-03-02 15:39:04632. `ctrl+o` goto symbol. `ctrl+l` goto line.
chaopengba312ce2017-02-12 03:38:25643. <code>ctrl+`</code> toggle terminal.
65
66## Tips
67
68### On laptop
69
chaopengca285112017-03-02 15:39:0470Because we use ycmd to enable auto completion. We can disable CPP autocomplete
71and index to save battery.
72
73```
74"C_Cpp.autocomplete": "Disabled",
75"C_Cpp.addWorkspaceRootToIncludePath": false
76```
77
78### Enable Sublime-like minimap
79
80```
81"editor.minimap.enabled": true,
82"editor.minimap.renderCharacters": false
83```
chaopengba312ce2017-02-12 03:38:2584
85### More
86
87https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/README.md