vscode - RicoJia/notes GitHub Wiki

========================================================================

Basics

========================================================================

  1. hotkeys

    1. Navigation
      • c+~ to open terminal
      • ctrl+enter to open file in vertical split
      • c+s+x see extensions
      • ctrl+shift+- for previous cursor position. ctrl+alt+- for next cursor position
    2. c+, for settings
      • c+s+p for settings.json
    3. ctrl + o, open file
      • ctrl + k + o opens folder
    4. see installations, <F1>
    5. debug
      • f9 - breakpoint
      • f5 start debugging
      • c+` to toggle console
      • c+s+` for new terminal
    6. c+f, local string search
      • c+s+f, cross file search
      • alt+f all search
    7. c-s-e is emoji.
      • go to sudo ibus-setup (without sudo you will see import error of gi)
  2. Plugins

    • markdown all in one

    • tabine

      • diabled "" autocomplete so autodocstring can work properly
    • AREPL: click on tab to see it

    • github copilot

    • autodocstring

    • relative go-to

      • when in doubt, check out ~/.vscode
      • alt+s for select, alt+g with +/- numbers
    • Arepl

      from arepl_dump import dump
      dump()
      
    • vsnips

    • gitlens

      1. see commit, diff
        • <F1>-git all changes
        • <F1> file history
        • gitlens arrow icon, click multiple times
      2. make commit quickly
        • <F1> -> git commit
        • undo a commit: gitlens
      3. open file remotely; open pr
        • Without any changes to git remote, do remotes->globe icon
        • Else, do gitlens -> remote -> +
    • vscode-vim: insertion mode works

      • -> <c-w>
      • disable
        "vim.handleKeys": {
            "<C-x>": false,
            "<C-w>": false,
            "<C-l>": false,
        },
        
      • "vim.useSystemClipboard": true
    • Web development

      • installed prettier: code formatter: typescript, javascript, html, css, graphQL; live preview: see the html page;
      • vscode icons
  3. Keybindings

    1. reference: https://code.visualstudio.com/docs/getstarted/keybindings
    2. when accepts a bool variable
    3. custom commands are a pain.
      1. You can do something like with built-in variables
      {
          "key": "ctrl+shift+y",
          "command": "workbench.action.terminal.sendSequence",
          "args": {
              "text": "echo -n '${fileDirname}' | xclip -sel clip \u000D"
          }
      },  
      
    
    
  4. Use mouse less

    • How to switch panes?
  5. Explore version lens Sync

========================================================================

C++ Setup

========================================================================

  1. Install Clangd
  2. Make Clangd aware of the commands
    cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=1
    cmake --build build/
    cp build/compile_commands.json . #in the project folder where CMakeLists.txt gets defined
    
    • for moxi_dev
    catkin profile add compile_commands
    catkin profile set compile_commands
    catkin config --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1
    catkin config -x suffix
    # run this command at diligent_ws.
    python collect_compile_commands.py buildcompile_commands(The build dir)
    

========================================================================

Quirks

========================================================================

  1. when you see that your changes in vscode is not showing up in git status, likely it's vscode not saving.
⚠️ **GitHub.com Fallback** ⚠️