# vscode 設置
## 快捷鍵
| 鍵位 | 功能 |
| -------- | -------- |
| ⌘+/ | 單行註解 |
| ⌘+\ | 在右側開啟視窗 |
| shift+⌥+A|多行註解|
| ⌘+L | 選取整行|
| ⌘+j | 顯示底下terminal |
| ⌘+x | 整行刪除 |
| ⌥+shift+up(down)| 複製一整行|
| option+上下鍵 | 一整行上下移動 |
| ⌥+(1,2,3,4)|在上方視窗移動|
| ⌥+O| 在下方多一行空白|
| ⌘+P|快速開啟檔案|
| ⌘+B|隱藏左側工具列|
| ⌘+D|多重選取修改(要先移到要改的字)|
| ⌘+T|到變數或函式|
| ⌘+鼠標移動|查看屬性|
| ⌘+shift+f|global find|
| option+shift+f|自動排版|
https://vocus.cc/article/amp/62473ca3fd8978000197653f
https://hackmd.io/@carlochuang/vscode-hotkey
## 重設工具列

## 設定font size
按command + shift + p ,打上user settings 選json那個

進到setting.json,加上
```json
"editor.fontSize": 15,
```
就可以更改大小

## mac 兩指縮放
進入設置

打上schemas後點擊藍色的字

加上這串"editor.mouseWheelZoom": true,

## 自動存擋
在file中勾選auto save

## 自動排版
在設定中打C_Cpp.clang_format_fallbackStyle,把原本是Visual studio 改成以下,其中ColumnLimit: 0是每行寬度無限
```json
{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}
````

按下 option+shift+f 就可自動排版
https://zamhuang.medium.com/vscode-如何在-vscode-上自定義-c-的-coding-style-c8eb199c57ce
或是設定存檔時自動排版

## 顯示空格與空白
1.打开setting,在搜索框中输入renderControlCharacters,选中勾选框,即可显示tab.
2.在搜索框中输入renderWhitespace,选择all,即可显示空格.
## 隱藏特定文件
在setting加上這段
\*\*代表所有文件夾內
```json=
"files.exclude": {
"**/*.bin": true,
}
```
## c++環境
### windows MinGW 安裝與其他設定
- [進入 MinGW 下載頁面選取 mingw-get-setup.exe (檔案會自動下載)](https://sourceforge.net/projects/mingw/)

- 開啟下載下來的程式,選擇下一步</br>

- 選擇安裝位置後繼續 (與描述檔有關,除非你知道怎麼弄否則不要動)

- 安裝畫面</br>

- 安裝完後會啟動 MinGW Installer Manager,找到 mingw32-gcc-g++ (bin) 點取左方窗格,選擇 Mark for Installation

- 選左側 All Packages,找到 mingw32-gdb (bin) 點取左方窗格,選擇 Mark for Installation

- 選擇 Installation --> Apply Change

- 點選 Apply</br>

- 安裝中,安裝完成後點選 Close</br>

- 開啟檔案總管 --> 電腦 --> 內容

- 選取右側側進階系統設定

- 選擇環境變數</br>

- 在下面的系統變數找到 Path</br>

- 新增 C:\MinGW\bin 點選確定</br>

- 環境變數變更完畢後重新啟動
- 或在終端機輸入 `git clone https://github.com/Bruce762/vscode-cplusplus-setting.git`

- 在資料夾中新增 .vscode 資料夾

- 解壓縮後從下載下來的東西加入畫面中(畫面的四個檔案)

先ctrl+shift+p然後選取這個

更改這些配置



### vscode內設定
在extension下載

下載這個打字會出現提示字

還有code runner

然後進入設置

打上code-runner進行一些設定

每次執行時清空terminal

執行時鼠標不跳到terminal(不勾)

在terminal上執行(一定要勾才能輸入)

執行前自動存擋

到設置中的debug shortcut取消勾選即可刪除Run C/C++ File的按鈕


現在只要按下快捷鍵control+option+n就可以執行程式
## code runner 改編譯器版本
不要用原本的run,用code runner的
先到setting改成這樣

還沒結束,到code runner 的extension setting 找到executor map然後點進去setting.json

另一種方式是按command + shift + p ,打上user settings 選json那個

然後cpp那行改成這樣
```json
"cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
```

## cph
### 改編譯器版本

到setting的args貼上 -std=c++17

### 關自動顯示judge
關掉這個不然很煩

## Debug
你以為可以執行程式就結束了嗎,當然還有debug囉。
**很重要!!!如果不行debug就直接刪掉.vscode裡面的東西就可以重選一次編譯器**
不然就直接
```git clone https://github.com/Bruce762/Mac_cPlusPlus_dbg_setting.git```
首先隨便點一個c++程式

按下快捷鍵command+shift+p出現查詢

選擇configure Task

點擊clang++推薦用clang(clang是c,clang\++是c++)

出現.vscode底下的task.json

改成c++17的話要添加這兩個變量,
```md
"_std=c++17", //add
"_stdlib=libc++", , //add
````

先不要管task.json,然後到這邊點create a launch.json file

跳出launch.json後點擊右下方的Add Configuration

點C/C++: (lldb) Launch
lldb是指debug

program的"輸入程式名稱,例如 ${workspaceFolder}/a.out"改成\${fileDirname}/\${fileBasenameNoExtension}

再增加變量preLaunchTask

其中preLaunchTask的值到task.json中的label的值複製下來
```"preLaunchTask":"C/C++:clang++建置使用中檔案"```


externalConsole改成true,執行時terminal就會變成獨立視窗

name對應到左上角的名子

最後按下快捷鍵fn+f5就可以開心debug(Debug C/C++ File)
fn+control+f5只是執行(Run C/C++ File)
1. continue:只會在中斷底點上移動
2. step over:逐行執行,碰到含式不會進去
3. step into:逐行執行,碰到含式會進去
4. step out:如果在函式中就會跳出來,但碰到中斷點會被擋住。跳出來後依然在當初進入函式的位置。如果在main中執行,因為main沒辦法再跳出來了,所以就執行到中斷點,有點類似continue
5. restart:重新執行一次
6. stop:停止程式

在func中直接輸入arr會只有跑出一個地址跟一個值。要在後面加上要的大小才會變成是一連串

### 沒有自動補全
這個開啟

刪掉這個或重載

參考鏈結 https://b23.tv/OKlesun
## c++ 停用紅色錯誤波浪
```
.vscode中setting新增 "C_Cpp.errorSquiggles": disable",
```

## c++ bit/stdc++.h 不見
先用iostream的definition

再找到在finder中的位置

創建bits資料夾

在termina cd 到bits後創建stdc++.h

在stdc++.h貼上以下程式
```cpp=
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
```
貼完後還是沒用就到/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1貼上bits
## 插件
以power mode為例,"poermode,enabled": true要複製到setting json裡面

在commend+shift+p 中打 setting json

粒子效果

自動排版

背景主題


自動輸出答案

html tag自動對齊

查看css

縮排線

顏色設定

彩虹縮排

https://ithelp.ithome.com.tw/m/articles/10267465
https://tw511.com/a/01/12559.html
## python 改環境版本
要先去下載python的插件

## markdown

