blob: 6a7c67ca45fcaf69c20fa5e74ea6092f6115c83b [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
chaopeng5c66dfe2017-03-22 13:51:4513`F1` paste
14`ext install cpptools you-complete-me clang-format chromium-codesearch`
15then enter. For more extensions:
16https://marketplace.visualstudio.com/search?target=vscode
chaopengba312ce2017-02-12 03:38:2517
18Highly recommend you also install your favorite keymap.
19
20An Example to install eclipse keymaps `ext install vscode-eclipse-keybindings`.
21You can search keymaps here.
22https://marketplace.visualstudio.com/search?target=vscode&category=Keymaps
23
24
25## Settings
26
27Open Settings `File/Code - Preferences - Settings` and add the following
28settings.
29
30```
31{
32 "editor.tabSize": 2,
33 "editor.rulers": [80],
chaopeng5c66dfe2017-03-22 13:51:4534 "[cpp]": {
35 "editor.quickSuggestions": true
36 },
chaopengba312ce2017-02-12 03:38:2537 // Exclude
38 "files.exclude": {
39 "**/.git": true,
40 "**/.svn": true,
41 "**/.hg": true,
42 "**/.DS_Store": true,
43 "**/out": true
44 },
45 // YCM
46 "ycmd.path": "<your_ycmd_path>",
47 "ycmd.global_extra_config":
48 "<your_chromium_path>/src/tools/vim/chromium.ycm_extra_conf.py",
49 "ycmd.confirm_extra_conf": false,
chaopengca285112017-03-02 15:39:0450 "ycmd.use_imprecise_get_type": true,
51 // clang-format
chaopeng6fca2b02017-03-03 19:10:5152 "clang-format.executable": "<your_depot_tools>/clang-format",
53 "clang-format.style": "file"
chaopengba312ce2017-02-12 03:38:2554}
55```
56
57### Install auto-completion engine(ycmd)
58
59```
60$ git clone https://github.com/Valloric/ycmd.git ~/.ycmd
61$ cd ~/.ycmd
62$ ./build.py --clang-completer
63```
64
65## Work flow
66
671. `ctrl+p` open file.
chaopengca285112017-03-02 15:39:04682. `ctrl+o` goto symbol. `ctrl+l` goto line.
chaopengba312ce2017-02-12 03:38:25693. <code>ctrl+`</code> toggle terminal.
chaopeng5c66dfe2017-03-22 13:51:45704. `F1` - `CodeSearchOpen` open current line in code search on chrome.
715. `F1` - `CodeSearchReferences` open XRef Infomation of current symbol.
726. Use right click menu call `go to definition` or `peek definition`.
737. Use right click menu call `find all references`.
chaopengba312ce2017-02-12 03:38:2574
75## Tips
76
77### On laptop
78
chaopengca285112017-03-02 15:39:0479Because we use ycmd to enable auto completion. We can disable CPP autocomplete
chaopeng5c66dfe2017-03-22 13:51:4580and index to save battery. We can also disable git status autorefresh to save
81battery.
chaopengca285112017-03-02 15:39:0482
83```
chaopeng5c66dfe2017-03-22 13:51:4584"git.autorefresh": false,
chaopengca285112017-03-02 15:39:0485"C_Cpp.autocomplete": "Disabled",
86"C_Cpp.addWorkspaceRootToIncludePath": false
87```
88
89### Enable Sublime-like minimap
90
91```
92"editor.minimap.enabled": true,
93"editor.minimap.renderCharacters": false
94```
chaopengba312ce2017-02-12 03:38:2595
96### More
97
98https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/README.md