lytex / vscode-setup

Some small scripts and configurations I use to develop python code using VSCode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vscode-setup

Some small scripts and configurations I use to develop python code using VSCode

disable vim mode

Ctrl+K, Ctrl+V to toggle vim mode

Ansible setup

Running sudo ansible-playbook root_install.yaml will:

  • install git, python3-pip, virtualenvwrapper, ipython
  • install zsh, fzf
  • install vscodium
  • install Sourcetrail
  • download (not install) Fura Mono Nerd Font and Fira Code

Running ansible-playbook user_install.yaml setting will:

  • Install all the vscodium plugins that I use (see list below)
  • create color and debug IPython profiles
  • Install zsh-autosuggestions and zsh-syntax-highlighting
  • Install zsh powerlevel10k theme

mkvscode_full-activate

  • This script
  • At the top of the script, venvs=`echo $HOME/.virtualenvs/*/` defines where to look for virtual environments, which by default is the virtualenvwrapper WORKON_HOME variable. If you want to change your virtual enviroment location, you have to change this path. However, the script assumes your virtual environment are all located under a common top directory:
/foo/bar/myproject/bin/activate
/foo/bar/http_requester/bin/activate
/foo/bar/scrapy/bin/activate
...

in this case, venvs=`echo /foo/bar/*/`

Useful vscode extensions

Git

Markdown

Python

Other languages

Format/color

Misc

Keyboard shortcuts

  • ctrl+shift+F5 -> Revert (Reload) File
  • alt+Z -> Toggle word wrapping

Integrated terminal

  • ctrl+shift+T -> Open a new terminal (shell launcher)
  • ctrl+alt+J -> Toggle terminal
  • ctrl+` -> Toggle between terminal and editor focus
  • ctrl+k ctrl+shift+n -> Switch to next terminal
  • ctrl+k ctrl+shift+p -> Switch to previous terminal
  • ctrl+shift+N -> Switch to Nth terminal (N=1-9)

IPython

  • F5 -> Write run 'path/to/script.py' into the terminal (assumes it's an IPython terminal)
  • F9 -> Copy-paste selection into terminal
  • Ctrl+J, Ctrl+Q -> Create a new line in IPython without executing
  • Esc, Enter -> Execute current IPython cell now without having to scroll to the bottom
  • Ctrl+Q -> Extract caller's enviroment to the IPython shell. Note that this it overwrites the predefined shortcut for exiting VSCode
  • Customize text color
  • Move ipython_config.py to ~/.ipython/profile_default/ipython_config.py (only newer IPython versions have syntax highlighting)

tmux

  • Ctrl+B -> Ctrl+Shift+B Reassigns workbench.action.toggleSidebarVisibility to use tmux shortcuts
  • Ctrl+K, U -> Keep unsaved and close saved files only
  • Ctrl+K, W -> Whack and close (discard unsaved files)

vscode tricks

  • Ctrl+K, Enter -> Keep current file from closing (italics means it's opened in preview mode and opening a new file will replace it)
  • F12 -> Go to Definition
  • Ctrl+F12 -> Go to Implementation
  • Shift+F12 -> Go to References

refactoring

  • F2 -> Rename symbol consistently with language syntax
  • Right click
    • Extract method
    • Extract variable

vscode cheatsheet

Common shortcuts

  • Ctrl+F -> Search
  • Ctrl+H -> Search and replace
    • Enter -> Single replace
    • Ctrl+Alt+Enter -> Replace all
    • Alt+R -> Toggle Regex
  • Alt+Ctrl+- -> Back
  • Ctrl+Shift+- -> Forward

Snippets

  • Ctrl+B, Ctrl+Q -> Extract caller's enviroment to the IPython shell.
  • Ctrl+B, Ctrl+E -> from IPython import embed; embed()
  • Ctrl+B, Ctrl+B -> Set Breakpoint with IPython embed()
  • Ctrl+Shift+R -> Rerun: Reload all modules an run on IPython %load_ext autoreload %autoreload run

Fonts

  • I use Fira Code, a monospaced font with programming ligatures.

Command Menu

  • Open with Ctrl+Shift+P
  • Terminal: Rename to rename current integrated terminal

Tricks

pylint

  • To select the proper pylint path for your project, set .vscode/settings.json -> "python.linting.pylintPath": "cd /home/user/full/path/to/code && pylint"

About

Some small scripts and configurations I use to develop python code using VSCode

License:MIT License


Languages

Language:Python 81.2%Language:Shell 18.8%