Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Use Visual Studio Code on Chromium code base | 1 # Visual Studio Code Dev |
| 2 | 2 |
| 3 Visual Studio Code is a free, lightweight and powerful code editor for Windows, | |
| 4 Mac and Linux, based on Electron/Chromium. It has built-in support for | |
| 5 JavaScript, TypeScript and Node.js and a rich extension ecosystem that adds | |
| 6 intellisense, debugging, syntax highlighting etc. for many languages (C++, | |
| 7 Python, Go). It works without too much setup. Get started | |
| 8 [here](https://code.visualstudio.com/docs). | |
|
Nico
2017/04/06 14:23:23
People who read this doc probably know this alread
ljusten (tachyonic)
2017/04/10 12:07:58
This is written for Nooglers who read through http
pmarko
2017/04/10 15:20:11
I agree that especially for a tool/IDE which is ne
| |
| 9 | |
| 10 It is NOT a full-fledged IDE like Visual Studio. The two are completely | |
| 11 separate products. The only commonality with Visual Studio is that both are | |
| 12 from Microsoft. | |
| 13 | |
| 14 Here's what works well: | |
| 15 | |
| 16 * Editing code works well especially when you get used to the [keyboard | |
| 17 shortcuts](https://code.visualstudio.com/docs/customization/keybindings). | |
| 18 VS Code is very responsive and can handle even big code bases like Chromium. | |
| 19 * Git integration is a blast. Built-in side-by-side view, local commit and | |
| 20 even extensions for | |
| 21 [history](https://marketplace.visualstudio.com/items?itemName=donjayamanne.g ithistory) | |
| 22 and | |
| 23 [blame view](https://marketplace.visualstudio.com/items?itemName=ryu1kn.anno tator). | |
| 24 * [Debugging](https://code.visualstudio.com/Docs/editor/debugging) works | |
| 25 well, even though startup times can be fairly high (~40 seconds with | |
| 26 gdb on Linux, much lower on Windows). You can step through code, inspect | |
| 27 variables, view call stacks for multiple threads etc. | |
| 28 * Opening files and searching solution-wide works well now after having | |
| 29 problems in earlier versions. | |
| 30 * Building works well. Build tools are easy to integrate. Warnings and errors | |
| 31 are displayed on a separate page and you can click to jump to the | |
| 32 corresponding line of code. | |
| 33 | |
| 3 [TOC] | 34 [TOC] |
| 4 | 35 |
| 5 [Visual Studio Code](http://code.visualstudio.com/) | 36 ## Updating This Page |
| 6 ([Wikipedia](https://en.wikipedia.org/wiki/Visual_Studio_Code)) is a | 37 |
| 7 multi-platform code editor that is itself based on Electron which is based on | 38 Please keep this doc up-to-date. VS Code is still in active development and |
| 8 Chromium. Visual Studio Code has a growing community and base of installable | 39 subject to changes. This doc is checked into the Chromium git repo, so if you |
| 9 extensions and themes. It works without too much setup. | 40 make changes, you have to |
| 10 | 41 [submit a change list](https://www.chromium.org/developers/contributing-code). |
| 11 ## Install extensions | 42 You may skip code review by adding |
| 12 | 43 ``` |
| 13 `F1` paste | 44 TBR=<foo>@chromium.org |
|
Nico
2017/04/06 14:23:23
This is true for all .md files, no need to mention
ljusten (tachyonic)
2017/04/10 12:07:58
This targets Nooglers specifically as well. A Noog
chaopeng
2017/04/10 14:24:54
I am OK with this part.
pmarko
2017/04/10 15:20:11
Not sure if the TBR part should be explicitly ment
Nico
2017/04/10 15:33:09
But following this argument, we'd add this note to
ljusten (tachyonic)
2017/04/11 08:45:03
I've removed the TBR part and linked to the docume
| |
| 14 `ext install cpptools you-complete-me clang-format chromium-codesearch` | 45 ``` |
| 15 then enter. For more extensions: | 46 where <foo> should be a valid comitter (e.g. your supervisor). |
| 16 https://marketplace.visualstudio.com/search?target=vscode | 47 |
| 17 | 48 All file paths and commands have been tested on Linux. Windows and Mac might |
| 18 Highly recommend you also install your favorite keymap. | 49 require a slightly different setup (e.g. `Ctrl` -> `Cmd`). Please update this |
| 19 | 50 page accordingly. |
| 20 An Example to install eclipse keymaps `ext install vscode-eclipse-keybindings`. | 51 |
| 21 You can search keymaps here. | 52 ## Setup |
| 22 https://marketplace.visualstudio.com/search?target=vscode&category=Keymaps | 53 |
| 23 | 54 ### Installation |
| 24 | 55 |
| 25 ## Settings | 56 Follow the steps on https://code.visualstudio.com/docs/setup/setup-overview. |
| 26 | 57 To run it on Linux, just navigate to the chromium/src folder and type 'code .' |
| 27 Open Settings `File/Code - Preferences - Settings` and add the following | 58 in a terminal. VS Code does not require project or solution files. However, it |
| 28 settings. | 59 does store workspace settings in a .vscode folder in your base directory. |
|
pmarko
2017/04/10 15:20:11
You might want to clarify that the "base directory
ljusten (tachyonic)
2017/04/11 08:45:03
Done. 'code' seems to open the most recent instanc
| |
| 29 | 60 |
| 30 ``` | 61 ### Useful Extensions |
| 31 { | 62 |
| 32 "editor.tabSize": 2, | 63 Up to now, you have a basic version of VS Code without much language support. |
| 33 "editor.rulers": [80], | 64 Next, we will install some useful extensions. Jump to the extensions window |
| 34 "[cpp]": { | 65 (`Ctrl+Shift+X`) and install these extensions, you will most likely use them |
| 35 "editor.quickSuggestions": true | 66 every day: |
| 36 }, | 67 |
| 37 // Exclude | 68 * ***C/C++*** - |
| 38 "files.exclude": { | 69 Complete C/C++ language support. |
|
pmarko
2017/04/10 15:20:11
nit: What does complete mean in this context?
ljusten (tachyonic)
2017/04/11 08:45:03
Added more buzzwords.
| |
| 39 "**/.git": true, | 70 * ***Python*** - |
| 40 "**/.svn": true, | 71 Python linting, debugging, intellisense, code formatting etc. |
| 41 "**/.hg": true, | 72 * ***Toggle Header/Source*** - |
| 42 "**/.DS_Store": true, | 73 Toggles between .cc and .h with `F4`. The C/C++ extension supports this as |
| 43 "**/out": true | 74 well through `Alt+O`. Last time I checked this was very laggy, but they |
| 44 }, | 75 might have improved it since, so this extension might not be necessary. |
| 45 // YCM | 76 * ***Protobuf support*** - |
| 46 "ycmd.path": "<your_ycmd_path>", | 77 Syntax highlighting for .proto files. |
| 47 "ycmd.global_extra_config": | 78 * ***you-complete-me*** - |
| 48 "<your_chromium_path>/src/tools/vim/chromium.ycm_extra_conf.py", | 79 YouCompleteMe code completion for VS Code. It works fairly well in Chromium. |
| 49 "ycmd.confirm_extra_conf": false, | 80 * ***Rewrap*** - |
| 50 "ycmd.use_imprecise_get_type": true, | 81 Wrap lines at 80 characters with `Alt+Q`. |
| 51 // clang-format | 82 |
| 52 "clang-format.executable": "<your_depot_tools>/clang-format", | 83 To install You-Complete-Me, enter these commands in a terminal: |
| 53 "clang-format.style": "file" | |
| 54 } | |
| 55 ``` | |
| 56 | |
| 57 ### Install auto-completion engine(ycmd) | |
| 58 | 84 |
| 59 ``` | 85 ``` |
| 60 $ git clone https://github.com/Valloric/ycmd.git ~/.ycmd | 86 $ git clone https://github.com/Valloric/ycmd.git ~/.ycmd |
| 61 $ cd ~/.ycmd | 87 $ cd ~/.ycmd |
| 62 $ ./build.py --clang-completer | 88 $ ./build.py --clang-completer |
| 63 ``` | 89 ``` |
| 64 | 90 |
| 65 ## Work flow | 91 The following extensions might be useful for you as well: |
| 66 | 92 |
| 67 1. `ctrl+p` open file. | 93 * ***Annotator*** - |
| 68 2. `ctrl+o` goto symbol. `ctrl+l` goto line. | 94 Git blame view. |
| 69 3. <code>ctrl+`</code> toggle terminal. | 95 * ***Git History (git log)*** - |
| 70 4. `F1` - `CodeSearchOpen` open current line in code search on chrome. | 96 Git history view. |
| 71 5. `F1` - `CodeSearchReferences` open XRef Infomation of current symbol. | 97 * ***chromium-codesearch*** - |
| 72 6. Use right click menu call `go to definition` or `peek definition`. | 98 Code search (CS) integration, see [Chromium Code |
| 73 7. Use right click menu call `find all references`. | 99 Search](https://cs.chromium.org/), in particular *open current line in CS*, |
| 74 | 100 *show references* and *go to definition*. Very useful for existing code. By |
| 75 ## Tips | 101 design, won't work for code not checked in yet. Overrides default C/C++ |
| 76 | 102 functionality. Had some issues last time I tried (extensions stopped |
| 77 ### On laptop | 103 working), so use with care. |
| 78 | 104 * ***change-case*** - |
| 79 Because we use ycmd to enable auto completion. We can disable CPP autocomplete | 105 Quickly change the case of the current selection or current word. |
| 80 and index to save battery. We can also disable git status autorefresh to save | 106 * ***Instant Markdown*** - |
| 81 battery. | 107 Instant markdown (.md) preview in your browser as you type. This document |
| 108 was written with this extension! | |
| 109 * ***Clang-Format*** - | |
| 110 Format your code using clang-format. The C/C++ extension already supports | |
| 111 format-on-save (see `C_Cpp.clang_format_formatOnSave` setting). This | |
| 112 extension adds the ability to format a document or the current selection on | |
| 113 demand. | |
| 114 | |
| 115 Also be sure to take a look at the | |
| 116 [VS Code marketplace](https://marketplace.visualstudio.com/VSCode) to check out other | |
| 117 useful extensions. | |
| 118 | |
| 119 ### Color Scheme | |
| 120 Press `Ctrl+Shift+P, color, Enter` to pick a color scheme for the editor. There | |
| 121 are also tons of [color schemes available for download on the | |
| 122 marketplace](https://marketplace.visualstudio.com/search?target=VSCode&category= Themes&sortBy=Downloads). | |
| 123 | |
| 124 ### Usage Tips | |
| 125 * `Ctrl+P` opens a search box to find and open a file. | |
| 126 * `F1` or `Ctrl+Shift+P` opens a search box to find a command (e.g. Tasks: Run | |
| 127 Task). | |
| 128 * `Ctrl+K, Ctrl+S` opens the key bindings editor. | |
| 129 * ``Ctrl+` `` toggles the built-in terminal. | |
| 130 * `Ctrl+Shift+M` toggles the problems view (linter warnings, compile errors | |
| 131 and warnings). You'll swicth a lot between terminal and problem view during | |
| 132 compilation. | |
| 133 * `Alt+O` switches between the source/header file. | |
| 134 * `Ctrl+G` jumps to a line. | |
| 135 * `F12` jumps to the definition of the symbol at the cursor (also available on | |
| 136 right-click context menu). | |
| 137 * `Shift+F12` or `F1, CodeSearchReferences, Return` shows all references of | |
| 138 the symbol at the cursor. | |
| 139 * `F1, CodeSearchOpen, Return` opens the current file in Code Search. | |
| 140 * `Ctrl+D` selects the word at the cursor. Pressing it multiple times | |
| 141 multi-selects the next occurrences, so typing in one types in all of them, | |
| 142 and `Ctrl+U` deselects the last occurrence. | |
| 143 * `Ctrl+K, Z` enters Zen Mode, a fullscreen editing mode with nothing but the | |
| 144 current editor visible. | |
| 145 * `Ctrl+X` without anything selected cuts the current line. `Ctrl+V` pastes | |
| 146 the line. | |
| 147 | |
| 148 ## Setup For Chromium | |
| 149 | |
| 150 VS Code is configured via JSON files. This paragraph contains JSON configuration | |
| 151 files that are useful for Chromium development, in particular. See [VS Code | |
| 152 documentation](https://code.visualstudio.com/docs/customization/overview) for an | |
| 153 introduction to VS Code customization. | |
| 154 | |
| 155 ### Workspace Settings | |
| 156 Open the file chromium/src/.vscode/settings.json and add the following settings. | |
| 157 Remember to replace `<full_path_to_your_home>`! | |
| 158 | |
| 159 ``` | |
| 160 { | |
| 161 // Default tab size of 2. | |
| 162 "editor.tabSize": 2, | |
| 163 // Do not figure out tab size from opening a file. | |
| 164 "editor.detectIndentation": false, | |
| 165 // Add a line at 80 characters. | |
| 166 "editor.rulers": [80], | |
| 167 // Optional: Highlight current line at the left of the editor. | |
| 168 "editor.renderLineHighlight": "gutter", | |
| 169 // Optional: Don't automatically add closing brackets. It gets in the way. | |
| 170 "editor.autoClosingBrackets": false, | |
| 171 // Optional: Enable a tiny 30k feet view of your doc. | |
| 172 "editor.minimap.enabled": true, | |
| 173 "editor.minimap.maxColumn": 80, | |
| 174 "editor.minimap.renderCharacters": false, | |
| 175 // Trim tailing whitespace on save. | |
| 176 "files.trimTrailingWhitespace": true, | |
| 177 // Optional: Do not open files in 'preview' mode. Opening a new file in can | |
| 178 // replace an existing one in preview mode, which can be confusing. | |
| 179 "workbench.editor.enablePreview": false, | |
| 180 // Optional: Same for files opened from quick open (Ctrl+P). | |
| 181 "workbench.editor.enablePreviewFromQuickOpen": false, | |
| 182 | |
| 183 "files.associations": { | |
| 184 // Adds xml syntax highlighting for grd files. | |
| 185 "*.grd" : "xml", | |
| 186 // Optional: .gn and .gni are not JavaScript, but at least it gives some | |
| 187 // approximate syntax highlighting. Ignore the linter warnings! | |
| 188 "*.gni" : "javascript", | |
| 189 "*.gn" : "javascript" | |
| 190 }, | |
| 191 | |
| 192 "files.exclude": { | |
| 193 // Ignore build output folders. | |
| 194 "out*/**": true | |
| 195 }, | |
| 196 | |
| 197 // Wider author column for annotator extension. | |
| 198 "annotator.annotationColumnWidth": "24em", | |
| 199 | |
| 200 // C++ clang format settings. | |
| 201 "C_Cpp.clang_format_path": "<full_path_to_your_home>/depot_tools/clang-format" , | |
| 202 "C_Cpp.clang_format_sortIncludes": true, | |
| 203 "C_Cpp.clang_format_formatOnSave": true, | |
| 204 | |
| 205 // YouCompleteMe | |
| 206 "ycmd.path": "<full_path_to_your_home>/.vim/bundle/YouCompleteMe/third_party/y cmd", | |
| 207 "ycmd.global_extra_config": "<full_path_to_your_home>/chromium/src/tools/vim/. ycm_extra_conf.py", | |
| 208 "ycmd.confirm_extra_conf": false, | |
| 209 } | |
| 210 ``` | |
| 211 | |
| 212 ### Tasks | |
| 213 Next, we'll tell VS Code how to compile our code and how to read warnings and | |
| 214 errors from the build output. Copy the code below to | |
| 215 chromium/src/.vscode/tasks.json. This will provide 5 tasks to do basic things. | |
| 216 You might have to adjust the commands to your situation and needs. | |
| 217 | |
| 218 ``` | |
| 219 { | |
| 220 "version": "0.1.0", | |
| 221 "_runner": "terminal", | |
| 222 "showOutput": "always", | |
| 223 "echoCommand": true, | |
| 224 "tasks": [ | |
| 225 { | |
| 226 "taskName": "1-build_chrome_debug", | |
| 227 "command": "ninja -C out/Debug -j 2000 chrome", | |
| 228 "isShellCommand": true, | |
| 229 "isTestCommand": true, | |
| 230 "problemMatcher": { | |
| 231 "owner": "cpp", | |
| 232 "fileLocation": ["relative", "${workspaceRoot}"], | |
| 233 "pattern": { | |
| 234 "regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.* )$", | |
| 235 "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 | |
| 236 } | |
| 237 } | |
| 238 }, | |
| 239 { | |
| 240 "taskName": "2-build_chrome_release", | |
| 241 "command": "ninja -C out/Release -j 2000 chrome", | |
| 242 "isShellCommand": true, | |
| 243 "isBuildCommand": true, | |
| 244 "problemMatcher": { | |
| 245 "owner": "cpp", | |
| 246 "fileLocation": ["relative", "${workspaceRoot}"], | |
| 247 "pattern": { | |
| 248 "regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.* )$", | |
| 249 "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 | |
| 250 } | |
| 251 } | |
| 252 }, | |
| 253 { | |
| 254 "taskName": "3-build_all_debug", | |
| 255 "command": "ninja -C out/Debug -j 2000", | |
| 256 "isShellCommand": true, | |
| 257 "problemMatcher": { | |
| 258 "owner": "cpp", | |
| 259 "fileLocation": ["relative", "${workspaceRoot}"], | |
| 260 "pattern": { | |
| 261 "regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.* )$", | |
| 262 "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 | |
| 263 } | |
| 264 } | |
| 265 }, | |
| 266 { | |
| 267 "taskName": "4-build_all_release", | |
| 268 "command": "ninja -C out/Release -j 2000", | |
| 269 "isShellCommand": true, | |
| 270 "problemMatcher": { | |
| 271 "owner": "cpp", | |
| 272 "fileLocation": ["relative", "${workspaceRoot}"], | |
| 273 "pattern": { | |
| 274 "regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.* )$", | |
| 275 "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 | |
| 276 } | |
| 277 } | |
| 278 }, | |
| 279 { | |
| 280 "taskName": "5-build_test_debug", | |
| 281 "command": "ninja -C out/Debug -j 2000 unit_tests components_unittests brows er_tests", | |
| 282 "isShellCommand": true, | |
| 283 "problemMatcher": { | |
| 284 "owner": "cpp", | |
| 285 "fileLocation": ["relative", "${workspaceRoot}"], | |
| 286 "pattern": { | |
| 287 "regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.* )$", | |
| 288 "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 | |
| 289 } | |
| 290 } | |
| 291 }] | |
| 292 } | |
| 293 ``` | |
| 294 | |
| 295 ### Launch Commands | |
| 296 Launch commands are the equivalent of `F5` in Visual Studio: They launch some | |
| 297 program or a debugger. Optionally, they can run some task defined in | |
| 298 `tasks.json`. Launch commands can be run from the debug view (`Ctrl+Shift+D`). | |
| 299 Copy the code below to chromium/src/.vscode/launch.json and adjust them to | |
| 300 your situation and needs. | |
| 301 ``` | |
| 302 { | |
| 303 "version": "0.2.0", | |
| 304 "configurations": [ | |
| 305 { | |
| 306 "name": "Chrome Debug", | |
| 307 "type": "cppdbg", | |
| 308 "request": "launch", | |
| 309 "targetArchitecture": "x64", | |
| 310 "program": "${workspaceRoot}/out/Debug/chrome", | |
| 311 "args": [], // Optional command line args | |
| 312 "preLaunchTask": "1-build_chrome_debug", | |
| 313 "stopAtEntry": false, | |
| 314 "cwd": "${workspaceRoot}", | |
| 315 "environment": [], | |
| 316 "externalConsole": true | |
| 317 }, | |
| 318 { | |
| 319 "name": "Chrome Release", | |
| 320 "type": "cppdbg", | |
| 321 "request": "launch", | |
| 322 "targetArchitecture": "x64", | |
| 323 "program": "${workspaceRoot}/out/Release/chrome", | |
| 324 "args": [], // Optional command line args | |
| 325 "preLaunchTask": "2-build_chrome_release", | |
| 326 "stopAtEntry": false, | |
| 327 "cwd": "${workspaceRoot}", | |
| 328 "environment": [], | |
| 329 "externalConsole": true | |
| 330 }, | |
| 331 { | |
| 332 "name": "Custom Test Debug", | |
| 333 "type": "cppdbg", | |
| 334 "request": "launch", | |
| 335 "targetArchitecture": "x64", | |
| 336 "program": "${workspaceRoot}/out/Debug/unit_tests", | |
| 337 "args": ["--gtest_filter=*", | |
| 338 "--single_process", | |
| 339 "--ui-test-action-max-timeout=1000000", | |
| 340 "--test-launcher-timeout=1000000"], | |
| 341 "preLaunchTask": "5-build_test_debug", | |
| 342 "stopAtEntry": false, | |
| 343 "cwd": "${workspaceRoot}", | |
| 344 "environment": [], | |
| 345 "externalConsole": true | |
| 346 }, | |
| 347 { | |
| 348 "name": "Attach Debug", | |
| 349 "type": "cppdbg", | |
| 350 "request": "launch", | |
| 351 "targetArchitecture": "x64", | |
| 352 "program": "${workspaceRoot}/out/Debug/chrome", | |
| 353 "args": ["--remote-debugging-port=2224"], | |
| 354 "stopAtEntry": false, | |
| 355 "cwd": "${workspaceRoot}", | |
| 356 "environment": [], | |
| 357 "externalConsole": false | |
| 358 }] | |
| 359 } | |
| 360 ``` | |
| 361 | |
| 362 ### Key Bindings | |
| 363 To edit key bindings, press `Ctrl+K, Ctrl+S`. You'll see the defaults on the | |
| 364 left and your overrides on the right stored in the file `keybindings.json`. To | |
| 365 change a key binding, copy the corresponding key binding to the right. It's | |
| 366 fairly self-explanatory. | |
| 367 | |
| 368 You can bind any command to a key, even commands specified by extensions like | |
| 369 `CodeSearchOpen`. For instance, to bind `CodeSearchOpen` to `F2` to , simply add | |
| 370 `{ "key": "F2", "command": "cs.open" },`. | |
| 371 Note that the command title `CodeSearchOpen` won't work. You have to get the | |
| 372 actual command name from the [package.json | |
| 373 file](https://github.com/chaopeng/vscode-chromium-codesearch/blob/master/package .json) | |
| 374 of the extension. | |
| 375 | |
| 376 If you are used to other editors, you can also install your favorite keymap. | |
| 377 For instance, to install eclipse keymaps, install the | |
| 378 `vscode-eclipse-keybindings` extension. More keymaps can be found | |
| 379 [in the marketplace](https://marketplace.visualstudio.com/search?target=vscode&c ategory=Keymaps). | |
| 380 | |
| 381 Here are some key bindings that are likely to be useful for you: | |
| 382 | |
| 383 ``` | |
| 384 // Place your key bindings in this file to overwrite the defaults | |
| 385 [ | |
| 386 // Run the task marked as "isTestCommand": true, see tasks.json. | |
| 387 { "key": "ctrl+shift+t", "command": "workbench.action.tasks.test" }, | |
| 388 // Jump to the previous change in the built-in diff tool. | |
| 389 { "key": "ctrl+up", "command": "workbench.action.compareEditor.previo usChange" }, | |
| 390 // Jump to the next change in the built-in diff tool. | |
| 391 { "key": "ctrl+down", "command": "workbench.action.compareEditor.nextCh ange" }, | |
| 392 // Jump to previous location in the editor (useful to get back from viewing a sy mbol definition). | |
| 393 { "key": "alt+left", "command": "workbench.action.navigateBack" }, | |
| 394 // Jump to next location in the editor. | |
| 395 { "key": "alt+right", "command": "workbench.action.navigateForward" }, | |
| 396 // Get a blame view of the current file. Requires the annotator extension. | |
| 397 { "key": "ctrl+alt+a", "command": "annotator.annotate" }, | |
| 398 // Toggle header/source with the Toggle Header/Source extension (overrides the | |
| 399 // key binding from the C/C++ extension as I found it to be slow). | |
| 400 { "key": "alt+o", "command": "togglehs.toggleHS" }, | |
| 401 // Quickly run a task, see tasks.json. Since we named them 1-, 2- etc., it is | |
| 402 // suffucient to press the corresponding number. | |
| 403 { "key": "ctrl+r", "command": "workbench.action.tasks.runTask", | |
| 404 "when": "!inDebugMode" }, | |
| 405 // The following keybindings are useful on laptops with small keyboards such as | |
| 406 // Chromebooks that don't provide all keys. | |
| 407 { "key": "shift+alt+down", "command": "cursorColumnSelectDown", | |
| 408 "when": "editorTextFocus" }, | |
| 409 { "key": "shift+alt+left", "command": "cursorColumnSelectLeft", | |
| 410 "when": "editorTextFocus" }, | |
| 411 { "key": "shift+alt+pagedown", "command": "cursorColumnSelectPageDown", | |
| 412 "when": "editorTextFocus" }, | |
| 413 { "key": "shift+alt+pageup", "command": "cursorColumnSelectPageUp", | |
| 414 "when": "editorTextFocus" }, | |
| 415 { "key": "shift+alt+right", "command": "cursorColumnSelectRight", | |
| 416 "when": "editorTextFocus" }, | |
| 417 { "key": "shift+alt+up", "command": "cursorColumnSelectUp", | |
| 418 "when": "editorTextFocus" }, | |
| 419 { "key": "alt+down", "command": "scrollPageDown", | |
| 420 "when": "editorTextFocus" }, | |
| 421 { "key": "alt+up", "command": "scrollPageUp", | |
| 422 "when": "editorTextFocus" }, | |
| 423 { "key": "alt+backspace", "command": "deleteRight", | |
| 424 "when": "editorTextFocus && !editorReadonly" } , | |
| 425 { "key": "ctrl+right", "command": "cursorEnd", | |
| 426 "when": "editorTextFocus" }, | |
| 427 { "key": "ctrl+shift+right", "command": "cursorEndSelect", | |
| 428 "when": "editorTextFocus" }, | |
| 429 { "key": "ctrl+left", "command": "cursorHome", | |
| 430 "when": "editorTextFocus" }, | |
| 431 { "key": "ctrl+shift+left", "command": "cursorHomeSelect", | |
| 432 "when": "editorTextFocus" }, | |
| 433 ] | |
| 434 ``` | |
| 435 | |
| 436 ### Tips | |
| 437 | |
| 438 #### The `out` folder | |
| 439 Automatically generated code is put into a subfolder of out/, which means that | |
| 440 these files are ignored by VS Code (see files.exclude above) and cannot be | |
| 441 opened e.g. from quick-open (`Ctrl+P`). On Linux, you can create a symlink as a | |
| 442 work-around: | |
| 443 ``` | |
| 444 cd ~/chromium/src | |
| 445 mkdir _out | |
| 446 ln -s ../out/Debug/gen _out/gen | |
| 447 ``` | |
| 448 We picked _out since it is already in .gitignore, so it won't show up in git | |
| 449 status. | |
| 450 | |
| 451 Note: As of version 1.9, VS Code does not support negated glob commands, but | |
| 452 once it does, you can use | |
| 453 ``` | |
| 454 "!out/Debug/gen/**": true | |
| 455 ``` | |
| 456 in files.exclude instead of the symlink. | |
| 457 | |
| 458 #### Using VS Code as git editor | |
| 459 Add `[core] editor = "code --wait"` to your `~/.gitconfig` file in order to use | |
| 460 VS Code as editor for git commit messages etc. Note that the editor starts up | |
| 461 significantly slower than nano or vim. To use VS Code as merge tool, add | |
| 462 `[merge] tool = code`. | |
| 463 | |
| 464 #### Task Names | |
| 465 Note that we named the tasks `1-build_chrome_debug`, `2-build_chrome_release` | |
| 466 etc. This allows you to quickly execute tasks by pressing their number: | |
| 467 Press `Ctrl+P` and enter `task <n>`, where `<n>` is the number of the task. You | |
| 468 can also create a keyboard shortcut for running a task. `File > Preferences > | |
| 469 Keyboard Shortcuts` and add `{ "key": "ctrl+r", "command": | |
| 470 "workbench.action.tasks.runTask", "when": "!inDebugMode" }`. Then it's | |
| 471 sufficient to press `Ctrl+R` and enter `<n>`. | |
| 472 | |
| 473 #### Working on Laptop | |
| 474 Because autocomplete is provided by the You-Complete-Me extension, consider | |
| 475 disabling C/C++ autocomplete and indexing to save battery. In addition, you | |
| 476 might want to disable git status autorefresh as well. | |
| 82 | 477 |
| 83 ``` | 478 ``` |
| 84 "git.autorefresh": false, | 479 "git.autorefresh": false, |
| 85 "C_Cpp.autocomplete": "Disabled", | 480 "C_Cpp.autocomplete": "Disabled", |
| 86 "C_Cpp.addWorkspaceRootToIncludePath": false | 481 "C_Cpp.addWorkspaceRootToIncludePath": false |
| 87 ``` | 482 ``` |
| 88 | 483 |
| 89 ### Enable Sublime-like minimap | |
| 90 | |
| 91 ``` | |
| 92 "editor.minimap.enabled": true, | |
| 93 "editor.minimap.renderCharacters": false | |
| 94 ``` | |
| 95 | |
| 96 ### More | 484 ### More |
| 97 | 485 More tips and tricks can be found |
| 98 https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/README.md | 486 [here](https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/README.md ). |
| OLD | NEW |