# 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 ## 重設工具列 ![](https://i.imgur.com/fRUKSYN.png) ## 設定font size 按command + shift + p ,打上user settings 選json那個 ![](https://i.imgur.com/gyiN8ls.png) 進到setting.json,加上 ```json "editor.fontSize": 15, ``` 就可以更改大小 ![](https://i.imgur.com/UnWzPlK.png) ## mac 兩指縮放 進入設置 ![](https://i.imgur.com/OTORsnG.png) 打上schemas後點擊藍色的字 ![](https://i.imgur.com/Ues0QBD.png) 加上這串"editor.mouseWheelZoom": true, ![](https://i.imgur.com/cHbHn67.png) ## 自動存擋 在file中勾選auto save ![](https://i.imgur.com/yJgKpP8.png) ## 自動排版 在設定中打C_Cpp.clang_format_fallbackStyle,把原本是Visual studio 改成以下,其中ColumnLimit: 0是每行寬度無限 ```json {BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0} ```` ![](https://i.imgur.com/hFMphtn.png) 按下 option+shift+f 就可自動排版 https://zamhuang.medium.com/vscode-如何在-vscode-上自定義-c-的-coding-style-c8eb199c57ce 或是設定存檔時自動排版 ![](https://i.imgur.com/sBd33Vb.png) ## 顯示空格與空白 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/) ![](https://i.imgur.com/iQX86Gm.jpg) - 開啟下載下來的程式,選擇下一步</br> ![](https://i.imgur.com/4NaWJd6.jpg) - 選擇安裝位置後繼續 (與描述檔有關,除非你知道怎麼弄否則不要動) ![](https://i.imgur.com/gEoE7YR.jpg) - 安裝畫面</br> ![](https://i.imgur.com/h2GcYTj.jpg) - 安裝完後會啟動 MinGW Installer Manager,找到 mingw32-gcc-g++ (bin) 點取左方窗格,選擇 Mark for Installation ![](https://i.imgur.com/XFnhquc.png) - 選左側 All Packages,找到 mingw32-gdb (bin) 點取左方窗格,選擇 Mark for Installation ![](https://i.imgur.com/Z9aBkfR.png) - 選擇 Installation --> Apply Change ![](https://i.imgur.com/EJWDEhB.jpg) - 點選 Apply</br> ![](https://i.imgur.com/rRpfnKk.jpg) - 安裝中,安裝完成後點選 Close</br> ![](https://i.imgur.com/J9Aq2Gd.jpg) - 開啟檔案總管 --> 電腦 --> 內容 ![](https://i.imgur.com/EfaLPFX.jpg) - 選取右側側進階系統設定 ![](https://i.imgur.com/nClm3Q8.png) - 選擇環境變數</br> ![](https://i.imgur.com/AtPQmFO.jpg) - 在下面的系統變數找到 Path</br> ![](https://i.imgur.com/VBFVONm.jpg) - 新增 C:\MinGW\bin 點選確定</br> ![](https://i.imgur.com/YvtKYnt.jpg) - 環境變數變更完畢後重新啟動 - 或在終端機輸入 `git clone https://github.com/Bruce762/vscode-cplusplus-setting.git` ![](https://i.imgur.com/C1S8tnc.jpg) - 在資料夾中新增 .vscode 資料夾 ![](https://i.imgur.com/2zdy42E.jpg) - 解壓縮後從下載下來的東西加入畫面中(畫面的四個檔案) ![](https://i.imgur.com/BcY9RcU.jpg) 先ctrl+shift+p然後選取這個 ![螢幕擷取畫面 2023-11-01 203546.png](https://hackmd.io/_uploads/rJgIVI61QT.png) 更改這些配置 ![螢幕擷取畫面 2023-11-01 202959.png](https://hackmd.io/_uploads/S12eIa17T.png) ![螢幕擷取畫面 2023-11-01 203006.png](https://hackmd.io/_uploads/SkZ-LTkXa.png) ![螢幕擷取畫面 2023-11-01 203013.png](https://hackmd.io/_uploads/rkZb8pkQT.png) ### vscode內設定 在extension下載 ![](https://i.imgur.com/NvBRU1B.png) 下載這個打字會出現提示字 ![](https://i.imgur.com/7z2CjPz.png) 還有code runner ![](https://i.imgur.com/8Z8KHwK.png) 然後進入設置 ![](https://i.imgur.com/OTORsnG.png) 打上code-runner進行一些設定 ![](https://i.imgur.com/aDYFVu9.png) 每次執行時清空terminal ![](https://i.imgur.com/az2aN55.png) 執行時鼠標不跳到terminal(不勾) ![](https://i.imgur.com/Ixthjgf.png) 在terminal上執行(一定要勾才能輸入) ![](https://i.imgur.com/FLhdddA.png) 執行前自動存擋 ![](https://i.imgur.com/aqrLmWy.png) 到設置中的debug shortcut取消勾選即可刪除Run C/C++ File的按鈕 ![](https://i.imgur.com/tTMinOe.png) ![](https://i.imgur.com/xS0YOc6.png) 現在只要按下快捷鍵control+option+n就可以執行程式![](https://i.imgur.com/M8n0d3t.png) ## code runner 改編譯器版本 不要用原本的run,用code runner的 先到setting改成這樣 ![](https://i.imgur.com/V9kPJb9.png) 還沒結束,到code runner 的extension setting 找到executor map然後點進去setting.json ![](https://i.imgur.com/VIPFAj2.png) 另一種方式是按command + shift + p ,打上user settings 選json那個 ![](https://i.imgur.com/gyiN8ls.png) 然後cpp那行改成這樣 ```json "cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", ``` ![](https://i.imgur.com/md8lnJP.png) ## cph ### 改編譯器版本 ![截圖 2024-10-12 凌晨1.11.05](https://hackmd.io/_uploads/ry8d2AUyJe.png) 到setting的args貼上 -std=c++17 ![截圖 2024-10-12 凌晨1.11.15](https://hackmd.io/_uploads/ByLdhRIyJg.png) ### 關自動顯示judge 關掉這個不然很煩 ![image](https://hackmd.io/_uploads/SJD_Ik_kkg.png) ## Debug 你以為可以執行程式就結束了嗎,當然還有debug囉。 **很重要!!!如果不行debug就直接刪掉.vscode裡面的東西就可以重選一次編譯器** 不然就直接 ```git clone https://github.com/Bruce762/Mac_cPlusPlus_dbg_setting.git``` 首先隨便點一個c++程式 ![](https://i.imgur.com/3Hkp2Ry.png) 按下快捷鍵command+shift+p出現查詢 ![](https://i.imgur.com/dtQwwvI.png) 選擇configure Task ![](https://i.imgur.com/w360HKv.png) 點擊clang++推薦用clang(clang是c,clang\++是c++) ![](https://i.imgur.com/1iFg0Po.png) 出現.vscode底下的task.json ![](https://i.imgur.com/DzP5M03.png) 改成c++17的話要添加這兩個變量, ```md "_std=c++17", //add "_stdlib=libc++", , //add ```` ![](https://i.imgur.com/G8RRoGz.png) 先不要管task.json,然後到這邊點create a launch.json file ![](https://i.imgur.com/Zt2328V.png) 跳出launch.json後點擊右下方的Add Configuration ![](https://i.imgur.com/qR7DCb8.png) 點C/C++: (lldb) Launch lldb是指debug ![](https://i.imgur.com/60MlulF.png) program的"輸入程式名稱,例如 ${workspaceFolder}/a.out"改成\${fileDirname}/\${fileBasenameNoExtension} ![](https://i.imgur.com/UdtjGKw.png) 再增加變量preLaunchTask ![](https://i.imgur.com/gUziFJS.png) 其中preLaunchTask的值到task.json中的label的值複製下來 ```"preLaunchTask":"C/C++:clang++建置使用中檔案"``` ![](https://i.imgur.com/4GSfTV7.png) ![](https://i.imgur.com/rhUSPKY.png) externalConsole改成true,執行時terminal就會變成獨立視窗 ![](https://i.imgur.com/Ebqq5y3.png) name對應到左上角的名子 ![](https://i.imgur.com/7wPwXdo.png) 最後按下快捷鍵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:停止程式 ![](https://i.imgur.com/jGWsXKJ.png) 在func中直接輸入arr會只有跑出一個地址跟一個值。要在後面加上要的大小才會變成是一連串 ![](https://i.imgur.com/LVyD9oD.png) ### 沒有自動補全 這個開啟 ![](https://i.imgur.com/3yE868M.png) 刪掉這個或重載 ![](https://i.imgur.com/5UcwG9m.png) 參考鏈結 https://b23.tv/OKlesun ## c++ 停用紅色錯誤波浪 ``` .vscode中setting新增 "C_Cpp.errorSquiggles": disable", ``` ![截圖 2023-11-05 下午5.37.30.png](https://hackmd.io/_uploads/HJM0G1SX6.png) ## c++ bit/stdc++.h 不見 先用iostream的definition ![](https://i.imgur.com/BNuCE7T.png) 再找到在finder中的位置 ![](https://i.imgur.com/EgNmAxR.png) 創建bits資料夾 ![](https://i.imgur.com/0OgXJGl.png) 在termina cd 到bits後創建stdc++.h ![](https://i.imgur.com/NrcSPfd.png) 在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裡面 ![](https://i.imgur.com/SUeYsEA.png) 在commend+shift+p 中打 setting json ![](https://i.imgur.com/a3IfBQR.png) 粒子效果 ![](https://i.imgur.com/8nkkSaW.png) 自動排版 ![](https://i.imgur.com/jFrSr2G.png) 背景主題 ![](https://i.imgur.com/qGR4H4V.png) ![](https://i.imgur.com/Yrvc6Pz.png) 自動輸出答案 ![](https://i.imgur.com/D4a8imG.png) html tag自動對齊 ![](https://i.imgur.com/Cpofbze.png) 查看css ![](https://i.imgur.com/1g695iW.png) 縮排線 ![](https://i.imgur.com/C9CrXPj.png) 顏色設定 ![截圖 2023-11-03 下午4.14.28.png](https://hackmd.io/_uploads/Sk_MnXfQT.png) 彩虹縮排 ![](https://i.imgur.com/W3Wg9Vx.png) https://ithelp.ithome.com.tw/m/articles/10267465 https://tw511.com/a/01/12559.html ## python 改環境版本 要先去下載python的插件 ![](https://hackmd.io/_uploads/HkrIGgBka.png) ## markdown ![image](https://hackmd.io/_uploads/r16u7U_6kl.png) ![截圖 2025-04-01 凌晨1.40.15](https://hackmd.io/_uploads/BkdimIOTye.png)