blob: e071f5f6039710194ffbfe91374be092ec989f15 [file] [log] [blame] [view]
chaopengba312ce2017-02-12 03:38:251# Use Visual Studio Code on Chromium code base
2
3[Visual Studio Code](http://code.visualstudio.com/)
4([Wikipedia](https://en.wikipedia.org/wiki/Visual_Studio_Code)) is a
5multi-platform code editor that is itself based on Electron which is based on
6Chromium. Visual Studio Code has a growing community and base of installable
7extensions and themes. It works without too much setup.
8
9## Install extensions
10
11`ctrl+p` paste `ext install cpptools you-complete-me` then enter.
12For more extensions: https://marketplace.visualstudio.com/search?target=vscode
13
14Highly recommend you also install your favorite keymap.
15
16An Example to install eclipse keymaps `ext install vscode-eclipse-keybindings`.
17You can search keymaps here.
18https://marketplace.visualstudio.com/search?target=vscode&category=Keymaps
19
20
21## Settings
22
23Open Settings `File/Code - Preferences - Settings` and add the following
24settings.
25
26```
27{
28 "editor.tabSize": 2,
29 "editor.rulers": [80],
30 // CPP
31 "C_Cpp.clang_format_path": "<your_depot_tools_path>/clang-format",
32 "C_Cpp.clang_format_fallbackStyle": "Chromium",
33 // Exclude
34 "files.exclude": {
35 "**/.git": true,
36 "**/.svn": true,
37 "**/.hg": true,
38 "**/.DS_Store": true,
39 "**/out": true
40 },
41 // YCM
42 "ycmd.path": "<your_ycmd_path>",
43 "ycmd.global_extra_config":
44 "<your_chromium_path>/src/tools/vim/chromium.ycm_extra_conf.py",
45 "ycmd.confirm_extra_conf": false,
46 "ycmd.use_imprecise_get_type": true
47}
48```
49
50### Install auto-completion engine(ycmd)
51
52```
53$ git clone https://github.com/Valloric/ycmd.git ~/.ycmd
54$ cd ~/.ycmd
55$ ./build.py --clang-completer
56```
57
58## Work flow
59
601. `ctrl+p` open file.
612. `ctrl+shift+o` goto symbol. `ctrl+l` goto line.
623. <code>ctrl+`</code> toggle terminal.
63
64## Tips
65
66### On laptop
67
68Because we use ycmd to enable auto completion. we can disable CPP autocomplete
69to save battery. `"C_Cpp.autocomplete": "Disabled"`
70
71### More
72
73https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/README.md