Skip to content

Development Notes

Vu Anh edited this page Apr 10, 2023 · 25 revisions

VS Code

Random notes about Development

VS Code Shortcuts

# Line
Cut Line: Command X

# Format Document
CTRL-SHIFT-I (⌃⇧I) : Format Document

# Hide/Show Panel
⌃`  : Switching from terminal and editor
⌘b  : Toggle Sidebar Visibility

# Code Runner Extenions
⌃⌥N (Ctrl-Option-N): Run Code

# File
Ctrl-P: Browse Files...

# Editor Group
Split Left: Command `View: Split Editor Left` (VSEL)
Close Editor: Command `View: Close Editor` 
Change Group Order: Ctrl + Command + Arrows
Switch File in Group: Ctrl + Tab or Alt + Command + Arrows

## Natigate Objects
Shitf + Command + .: Very powerfull!!!
Command + Shitf + O: Find object (@local, #global)

## Multipleline Editing
Command + D

## Terminal
Ctrl-Shift-[
Ctrl-Shift-]

Mac Keyboard Symbols

  • is the Command () key.
  • is the Control key.
  • is the Option (alt) key.
  • is the Shift key.
  • is the Caps Lock key.
  • fn is the Function key.

VSCode C++

Syntax Highlighting

Extension C/C++ (C/C++ IntelliSense, debugging, and code browsing.)

C++ Setting

"C_Cpp.clang_format_fallbackStyle": "Google"
  • Run command C/C++: Enable Error Squiggles [1]

[1]: How To enable Error squiggles in VS code // complete solution

C++

Build and Run g++ code

g++ -std=c++17 -Wall -O2 -o "a" "a.cpp" && ./a < in
g++ -std=c++17 -Wall -O2 -o "program" "program.cpp"
export CPLUS_INCLUDE_PATH=/Library/Developer/CommandLineTools/usr/include/c++/v1/
g++ -std=c++17 -Wall -O2 -I/Library/Developer/CommandLineTools/usr/include/c++/v1/ -o "program" "program.cpp" 

C++ Coding Convention

Rule 1: Check pointer is null or not, just use boolean operator (don't use null or nullptr)

/* Good way */
if(!node) { } 

/* Bad ways */
if(node != nullptr) { }
if(node != NULL){ }

Reference: 1, 2

VSCode Tips

Open multiple files

cd problems/leetcode_id
code -r cpp/main/solution.cpp cpp/main/solution.h data/1.in data/1.out data/2.in data/2.out data/3.in data/3.out

Run program

bazel run cpp/main:solution < data/1.in

Convert notebooks to README

jupyter nbconvert notebook.ipynb --to markdown; mv notebook.md README.md

IDE Online

Clone this wiki locally