PROJECTS NOTES HOME

Vscode

1 vscode

1.1 vscode global config

Files that should be placed in C:\Users\<username>\AppData\Roaming\Code\User folder. Overrides Global VsCode settings.

1.1.1 settings.json

{
    "terminal.integrated.defaultProfile.windows": "Command Prompt",
    "git.enableSmartCommit": true,
    "editor.smoothScrolling": true,
    "explorer.confirmDelete": false,
    // fix the god damn pasting indentation
    "editor.formatOnPaste": false,


    // https://dev.to/brad_beggs/vs-code-vertical-rulers-for-prettier-code-3gp3
    "[git-commit]": {"editor.rulers": [50]},
    "[javascript]": {
	"editor.rulers": [
	    79
	]
    },
    "[python]": {
	"editor.rulers": [
	    79
	],
	// install "Black Formatter" extension for VsCode
	"editor.defaultFormatter": "ms-python.black-formatter",
	"editor.formatOnSave": true,
	"editor.codeActionsOnSave": {
	    "source.organizeImports": "never"
	},
    },
    "isort.args":["--profile", "black"],
    "black-formatter.args": ["--line-length", "79"],

    // https://github.com/vscode-django/vscode-django/issues/125
    // allow html tag completion in django html mode
    "emmet.includeLanguages": {
	"django-html": "html"
    },
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "explorer.confirmDragAndDrop": false,
    "editor.minimap.enabled": false,
    "gitlens.hovers.currentLine.over": "line",
    "workbench.sideBar.location": "right",
    "diffEditor.ignoreTrimWhitespace": false,
}

1.1.2 keybindings.json

[
    {
	"key": "alt+x",
	"command": "workbench.action.showCommands"
    },
    {
	"key": "ctrl+shift+p",
	"command": "-workbench.action.showCommands"
    }
]

1.2 vscode local single project config

Files that should be placed in .vscode folder of a project. The changes described in those files will be applied only for a particular project.

1.2.1 settings.json

// vscode settings for this particular project

// https://github.com/azegas/quotes/issues/9

// When launching terminal in a project, it does not activate virtual environment that *I* want (that is dedicated for this project).
// You open terminal, write `workon <nameofthevenv>` (previously you have to install mkvirtualenv(if on windows)) and you activate the needed venv. Good.
// But then you see that you need another terminal to run some commands.
// You open another terminal, do `workon <nameofthevenv>` once again. You need another terminal (for django shell for example), you do `workon <nameofthevenv>` again...

// Would it not be cool if vscode would know - "he is inside of this project directory, it is linked to `<nameofthevenv>` virtual environment,
// let me activate it in each new terminal instance'.

{
    "python.terminal.activateEnvInCurrentTerminal": true,
    "terminal.integrated.cwd": "C:\\Users\\Petras\\GIT\\test",
    "python.defaultInterpreterPath": "C:\\Users\\arvydas\\Envs\\test\\Scripts\\python.exe"
}

// Now when you launch new terminal now, it will automatically have shipping virtual environment activated.

1.2.2 launch.json

// File that must be in .vscode folder of the project, used for Django app debugging.

// Official docs - https://code.visualstudio.com/docs/editor/debugging
// Followed the docs, choose the debug option, python, django and the launhc.json was created automatically. Then could debug django app.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
	{
	    "name": "Python Debugger: Django",
	    "type": "debugpy",
	    "request": "launch",
	    "args": [
		"runserver"
	    ],
	    "django": true,
	    "autoStartBrowser": false,
	    "program": "${workspaceFolder}/manage.py"
	}
    ]
}

1.3 vscode shortcuts

C:\Users\<username>\AppData\Roaming\Code\User this is where the settings.json file lies, your customizations fall down here, can add custom things also.

You can jump to the definition with Ctrl+Click or open the definition to the side with Ctrl+Alt+Click.

F2 - rename symbol Ctrl+Shift+O - navigate symbols inside a file By typing : the symbols will be grouped by category Ctrl+T - jumping to a symbol across files ctrl w - close window Alt 1 2 3 - jump through files in the opened workplace(like split screen) Ctrl 1 2 3 - create/jump to first second or third window Ctrl + p - open a file Ctrl - o - open dired(explorer) here and now Ctrl + b - open/close navbar

  • c-k c-t - choose theme
  • syncing to other devices with github login in vs code…
  • c-shift-p - ope command pallet
  • f5 - run and debug ANY file
  • jupyter notebooks in vscode? what is it for
  • c-k c-o - open a folder(opens up nautilus)
  • shift+alt+click/up/down multiple cursors
  • ctrl+shift+k - delete entire line
  • f2 - rename variable
  • c+shift+i - format entire document
  • c+k c+f - format selection
  • c+shift+[] - fold unfold code
  • type "if" or "try" and then select some sugeested completion snippet..
  • emmet works just the same
  • c-` open terminal
  • c-, - open settings
  • C-1, C-2, C-3 - different windows
  • file->autosave - autosaves every little change
  • c-n - create new file
  • live server/live preview - html/css editing on the fly
  • c+shift+g git interface
  • run auto detected tasks(google when its useful)
  • c+k c+s customize shortcuts
  • eslint extensions for smth many downloads