ShortcutsExtensionsDebug C code in WSL (Windows)Debug (21-school iMac's)Синхронизация настроекВстроеннаяЧерез плагин Settings Sync
Shortcuts
cmd + p
- find by filename
cmd + shift + p
- command pallet for commands / settings
> render whitespaces
- показывать пробелы сначала открыть command pallet
> conver tab to spaces
- open settings.json from command pallete
Extensions
git merge confilic - попробовать для в консоли написать
git config merge.conflictStyle diff3
Thunder client - Более простой аналог Postman внутри VS Code (Rest API запросы)
Clang-Format - Code formatter (Форматирование кода по стилю)
settings.json
MacOS{ "explorer.confirmDragAndDrop": false, "explorer.confirmDelete": false, "cSpell.language": ",ru", "cSpell.userWords": [ "Gitlab", "develop", "mtasia", "реквеста" ], "files.autoSave": "afterDelay", "workbench.editorAssociations": { "*.ipynb": "jupyter-notebook" }, "[c]": { "editor.defaultFormatter": "ms-vscode.cpptools" }, "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4 }", "notebook.cellToolbarLocation": { "default": "right", "jupyter-notebook": "left" } }
C/C++ - run, debug
vim - emulator
settings.json
windows{ "files.autoSave": "afterDelay", "editor.renderWhitespace": "all", "vim.useCtrlKeys": false, "vim.vimrc.enable": true, "vim.vimrc.path": "C:\\Users\\LocAdmin\\.ideavimrc", "terminal.integrated.defaultProfile.windows": "Ubuntu-20.04 (WSL)", "cpplint.cpplintPath": "C:\\Users\\LocAdmin\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\Scripts\\cpplint.exe", "[c]": { "editor.defaultFormatter": "xaver.clang-format" }, "clang-format.language.c.style": "{ BasedOnStyle: Google, IndentWidth: 4, TabWidth: 4 }", }
keybindings.json
windows// Place your key bindings in this file to override the defaultsauto[] [ { "key": "f12", "command": "workbench.action.terminal.focus", }, { "key": "escape", "command":"workbench.action.focusActiveEditorGroup", "when":"!editorTextFocus" }, { "key": "ctrl+shift+\\", "command": "-workbench.action.terminal.focusTabs", "when": "terminalFocus && terminalProcessSupported || terminalProcessSupported && terminalTabsFocus" }, { "key": "alt+f12", "command": "terminal.focus" }, { "key": "ctrl+p", "command": "-workbench.action.quickOpen" }, { "key": "ctrl+alt+l", "command": "editor.action.formatDocument", "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor" }, { "key": "shift+alt+f", "command": "-editor.action.formatDocument", "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor" }, { "key": "ctrl+alt+l", "command": "editor.action.formatDocument.none", "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly" }, { "key": "shift+alt+f", "command": "-editor.action.formatDocument.none", "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly" } ]
code runner - run code easy
cpplint - сначала установить через brew intall cpplint. Закрыть терминал и открыть снова.
- На windows через
pip install cpplint
и добавить в переменные окружения
Better comments - todo highlighting
Code Spell Checker - орфография
Russian - Code Spell Checker - орфография
Makefile Tools - Быстрее и удобнее работать с make файлом (Надо перезапустить VScode и настроить путь до папки с makefile
Remote - Container
Remote - SSH
Remote - WSL (Windows only) Если нет такого значит работаешь из под винды
Debug C code in WSL (Windows)
- WSL - Устанавливаем необходимое барахло для комфорта софта и души
sudo apt -y install build-essential gdb gcc make valgrind \ cppcheck python3-pip clang mc vim && pip install cpplint
- Добавь в
Makefile
или в командуgcc
в консоли флаг-ggdb
, чтобы сформировать для дебагераgdb
информацию в бинарнике.
- VScode Command Panel
> Configure Default Build Task
- В настройках
RUN AND DEBUG
в VScode указать: - Путь до бинарника
"program": "${workspaceFolder}/build/Quest_4_pretty_print",
- Агрументы. Например перенаправление ввода
"args": ["<", "file.txt"],
For debug? "sourceFileMap": {"/build/glibc-S7xCS9": "/usr/src/glibc"}, // "sourceFileMap": { "//wsl$/Ubuntu-20.04" : "/" },
Не знаю будет ли влиять флаг -ggdb на бинарные файлы. Возможно стоит его убирать для релизов.
- Поставь точки остановки (brakepoints) в файле
- Запускай на кнопку play (F5)
- Если есть ошибки при дебаге пробуй https://programmerah.com/debugging-failed-under-vscode-ubuntu-unable-to-open-libc-start-c-raise-c-etc-33368/
mkdir -p /build/glibc-eX1tMB/ # Путь из ошибки cd /build/glibc-eX1tMB/ sudo apt install glibc-source # Скачай исходники tar -xvf /usr/src/glibc/glibc-2.31.tar.xz # Распакуй братуху, распакуй chmod 777 /build/glibc-eX1tMB/glibc-2.31/csu/libc-start.c
GDB можно пользоваться через командную строку
Mac
Debug (21-school iMac's)
- Поставить плагин lldb (?)
- Компилить в gcc с флагом -g
Синхронизация настроек
Встроенная
Через плагин Settings Sync
Можно создать разные privat gist на github для разных конфигураций и платформ либо через Pragmas указывать как что синхронизировать
- Включить auto update