Vs Code settings, compiler, user snippet and extension for C and C++ coding

VS CODE এ COMPLIER INSTALL করা:  

  1. প্রথমে এখানে ক্লিক করে MingW Download করতে হবে এবং install দিতে হবে।
  2. install হতে হতে একসময় নিচের মত ডায়লগ বক্স আসবে (১ নাং ছবি)।
  3. সেখান থেকে mingw-32 base এবং mingw32-gcc-g++ এই দুইটা অপশান সিলেক্ট করে mark for installation এ ক্লিক করতে হবে (২ নাং ছবি)
  4. এরপর এগুলা করা শেষ হলে বাম পাশের installation বাটনে ক্লিক করে apply changes বাটনে ক্লিক করে apply করে দিতে হবে। তাহলে ধীরে ধীরে এটা ইনষ্টল হয়ে যাবে।


ছবিঃ ১
ছবিঃ ২

ছবিঃ ৩


এখন আমার কাজ হবে mingw এর জন্য environtment variable path ঠিক করা। সেটা করার জন্য নিচের প্রসেস ফলো করুনঃ

  1. প্রথমে C drive এ যেতে হবে 
  2. এবার সেখান থেকে MingW folder এ ক্লিক করে ভেতরে ঢুকতে হবে (ছবি ১)
  3. সেখান থেকে bin নামক ফোল্ডারে ক্লিক করে ভিতরে ঢুকতে হবে (ছবি ২)
  4. এবার একদম উপর থেকে bin এর পাথ সিলেক্ট করে কপি করে নিতে হবে। (ছবি ৩)
  5. এবার কিবোর্ড থেকে windows বাটনে ক্লিক করতে হবে এবং environment variable সার্চ করতে হবে (ছবি ৪) সেখান থেকে edit the system environment অপশানে ক্লিক করতে হবে।
  6. এবার environment variable বাটনে ক্লিক করতে হবে (ছবি ৫)
  7. সেখান থেকে path নামে অপশানে ডাবল ক্লিক করতে হবে (ছবি ৬)
  8. এবার new বাটনে ক্লিক করে কপি করা পাথ পেষ্ট করতে হবে। এবং ওকে দিয়ে সবগুলা থেকে বের হয়ে যেতে হবে (ছবিঃ ৭)। ব্যাস আপনার কাজ শেষ

ছবিঃ ১



ছবিঃ ২


ছবিঃ ৩

ছবিঃ ৪

ছবিঃ ৫

ছবিঃ ৬

ছবিঃ ৭


Vs code এ c and c++ করার জন্য দরকারী extensions গুলা হলঃ


Note: অনেক vs code এ দেখা যায় এসব কিছু করার পরও কোড রান করতে সমস্যা হয় বা #include<stdio.h> বা অন্য যেকোন হেডার ফাইলের নিচে লাল দাগ চলে আসে। সেক্ষেত্রে এটা সমাধানের জন্য আপনাকে C/C++ complie run নামে এরো একটা extension install করতে হবে (নিচের ছবি দেখ)। এটা করলেই আপনার কাজ পুরাপুরি শেষ।




VS CODE SETTINGS (json file):
পুরা সেটিং ফাইলটা ডাউনলোড করতে এখানে ক্লিক করুন। অথবা নিচের থেকে কপি করুন;

C USER SNIPPET:
পুরা সেটিং ফাইলটা ডাউনলোড করতে এখানে ক্লিক করুন। অথবা নিচের থেকে কপি করুন;

C++ USER SNIPPET:
পুরা সেটিং ফাইলটা ডাউনলোড করতে এখানে ক্লিক করুন। অথবা নিচের থেকে কপি করুন;

VS code json settings:

{
    // terminal font family and font size
    "terminal.integrated.fontFamily": "Fira code",
    "terminal.integrated.fontSize": 14,
    // ===============================================
    "update.mode": "none",
    "tabnine.experimentalAutoImports": true,
    "editor.fontSize": 17,
    "editor.formatOnSave": true,
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "editor.wordWrap": "on",
    // "editor.fontLigatures": true,
    // font ligatures for cascadia code
    "editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'zero', 'onum'",
    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    },
    "[json]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    // cursor
    "editor.cursorSmoothCaretAnimation": "on",
    "editor.cursorBlinking": "expand",
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "workbench.editor.language detection": false,
    "workbench.editor.enablePreview": false,
    // =====================================customize comment color start=================================
    "editor.tokenColorCustomizations": {
        // "comments": "#ff0000ad",
        // customize the theme color:
        // "[Learn with Sumit - Shades of Grey]": {
        //     "comments": "#c3c3c3",
        // "variables": "#dc14ff",
        //     "keywords": "#ff1900",
        //     "functions": "#f95dc5",
        //     "types": "#FF0000",
        //     "strings": "#ff0000",
        //     "numbers": "#95ffd1",
        // },
        "textMateRules": [
            {
                "scope": "comment",
                "settings": {
                    "fontStyle": "italic"
                }
            }
        ]
    },
    /* "editor.tokenColorCustomizations": {
        "comments": "#4965a7" // change to any color you like
      }, */
    //======================================bracket colorizer of vs code start=======================
    "editor.guides.bracketPairs": "active",
    "editor.fontFamily": "'Cascadia Code','Fira Code','Operator Mono', Consolas, 'Courier New', monospace", //Fira Code
    "code-runner.terminalRoot": "/",
    "editor.renderWhitespace": "all",
    "code-runner.runInTerminal": true,
    "code-runner.saveAllFilesBeforeRun": true,
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.default.cppStandard": "c++20",
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        //=================================================================
        // C and C++ settings
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt.exe && timeout 5s $dir$fileNameWithoutExt.exe < input.txt > output.txt || (echo -n > output.txt && echo 'Time Limit Gone')",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt.exe && timeout 5s $dir$fileNameWithoutExt.exe < input.txt > output.txt || (echo -n > output.txt && echo 'Time Limit Gone')",
        // for  terminal output
        // "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt.exe && $dir$fileNameWithoutExt.exe",
        //====================================================================
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "python -u",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "scheme": "csi -script",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
        "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    },
    "git.openRepositoryInParentFolders": "never",
    "code-runner.executorMapByFileExtension": {
        ".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
        ".vbs": "cscript //Nologo",
        ".scala": "scala",
        ".jl": "julia",
        ".cr": "crystal",
        ".ml": "ocaml",
        ".zig": "zig run",
        ".exs": "elixir",
        ".hx": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        ".rkt": "racket",
        ".scm": "csi -script",
        ".ahk": "autohotkey",
        ".au3": "autoit3",
        ".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
        ".kts": "kotlinc -script",
        ".dart": "dart",
        ".pas": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".pp": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        ".hs": "runhaskell",
        ".nim": "nim compile --verbosity:0 --hints:off --run",
        ".csproj": "dotnet run --project",
        ".fsproj": "dotnet run --project",
        ".lisp": "sbcl --script",
        ".kit": "kitc --run",
        ".v": "v run",
        ".vsh": "v run",
        ".sass": "sass --style expanded",
        ".cu": "cd $dir && nvcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        ".ring": "ring",
        ".sml": "cd $dir && sml $fileName"
    },
    "workbench.iconTheme": "material-icon-theme",
    "workbench.colorTheme": "Learn with Sumit - Shades of Grey",
}


C User Snippet Setting:

{
// Place your snippets for c here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
// C structure
"Generating C structure": {
"prefix": "cst",
"body": [
"#include <stdio.h>",
"",
"int main()",
"{",
"",
"    $0",
"",
"    return 0;",
"}"
],
"description": "C language structure making with main() function"
}
}

C++ User Snippet Setting:

{
// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
// c++ structure
"C++ structure": {
"prefix": "cpp",
"body": [
"#include <bits/stdc++.h>",
"using namespace std;",
"",
"",
"",
"int main()",
"{",
"",
"    $0",
"",
"    return 0;",
"}"
],
"description": "C++ Structure generating"
},
// c++ class snippets
"class snippet": {
"prefix": "cls",
"body": [
"class ClassName",
"{",
"public:",
"    $0",
"    ",
"};"
],
"description": ""
},
// singly linked list Node snippet
"Generate Node class snippet": {
"prefix": "snode",
"body": [
"class Node",
"{",
"public:",
"    int val;",
"    Node *next;",
"    Node(int val)",
"    {",
"        this->val = val;",
"        this->next = NULL;",
"    }",
"};"
],
"description": "Node class snippet"
},
// doubly linked list node snippet
"doubly linked list snippet": {
"prefix": "dnode",
"body": [
"class Node",
"{",
"public:",
"    int val;",
"    Node *prev;",
"    Node *next;",
"    Node(int val)",
"    {",
"        this->val = val;",
"        this->prev = NULL;",
"        this->next = NULL;",
"    }",
"};"
],
"description": "doubly linked list snippet"
},
// binary search node for binary tree
"binary search node": {
"prefix": "bnode",
"body": [
"class Node",
"{",
"public:",
"    int val;",
"    Node *left;",
"    Node *right;",
"    Node(int val)",
"    {",
"        this->val = val;",
"        this->left = NULL;",
"        this->right = NULL;",
"    }",
"};"
],
"description": "Binary Search Node for Binary Tree"
}
}

=========================ধন্যবাদ =================================


Post a Comment

Previous Post Next Post