Editors & IDEs

Debian Development Machine Setup

Chapter 8 ยท Editors & IDEs on the Desktop

The languages are installed, so now you need somewhere to write code. This chapter is about setting up editors on devserver, not about learning them: VS Code Essentials, Learning Vim and Text Editors & IDEs Survey already teach how to use the tools. Here we deal with the Debian-specific parts: where to get VS Code from, how to keep it updated, how to choose a default editor for the whole system, and how to record your extensions so a rebuild is painless.

What You Already Have

command -v nano vim nvim code apt policy vim neovim code readlink -f "$(command -v editor)"

A Debian desktop already has nano, and you installed vim in Chapter 2. The last command shows where Debian's editor command currently points. That is the system's default terminal editor, which programs like Git and sudoedit call when they need you to type something. apt policy code will show nothing yet: VS Code is not in Debian's own repositories.

EditorTypeOn Debian 13Good for
nanoTerminalIncludedQuick edits to config files; the easy one to learn.
VimTerminalVersion 9.1 in Debian's repositories (vim)Fast editing anywhere, including over SSH on debserver.
NeovimTerminalVersion 0.10.4 in Debian's repositories (neovim)A modern, extensible take on Vim.
VS CodeGraphical IDENot in Debian; from Microsoft's repositoryLarger projects, debugging, extensions, integrated terminal and Git.

You do not have to choose one. A common pattern is VS Code for projects and a terminal editor for quick edits and for work over SSH. The rest of this chapter sets up that combination.

Installing VS Code from Microsoft's Repository

VS Code is Microsoft's program, not part of Debian, so you install it from Microsoft's own apt repository. That is a third-party repository: you are choosing to trust a company outside Debian to supply software that will run with your user's permissions, and to keep it updated. Linux Package Managers 3 explains what that trust involves, and Chapter 4 already showed you the same idea for the NVIDIA driver, though that one came from Debian. Do it deliberately, in three steps.

Step 1: Get Microsoft's signing key

sudo apt install wget gpg wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg

This downloads Microsoft's public key and converts it into the binary format apt uses. Piping a downloaded key into gpg is not the same risk as piping a downloaded script into bash, because gpg --dearmor only converts data and does not run it. Still, apply the habit from Chapter 1 and look at what you have:

gpg --show-keys /usr/share/keyrings/microsoft.gpg

This prints the key's owner and fingerprint. Compare the fingerprint with the one published by Microsoft before you rely on it; a key you obtained over HTTPS from Microsoft's own site is reasonable to trust, but the check costs a minute.

Step 2: Add the repository

Create /etc/apt/sources.list.d/vscode.sources in the same deb822 format you met in Chapter 2:

Types: deb URIs: https://packages.microsoft.com/repos/code Suites: stable Components: main Architectures: amd64,arm64,armhf Signed-By: /usr/share/keyrings/microsoft.gpg

Read the Signed-By line carefully. It tells apt that packages from this repository must be signed by this key, and that this key is trusted for this repository only. That keeps Microsoft's key from vouching for anything else.

Step 3: Install

sudo apt update sudo apt install code

Then check it with the Chapter 3 tools:

apt policy code # the repository line shows packages.microsoft.com code --version dpkg -S "$(command -v code)" type -a code
The installer shortcut
Microsoft also offers a .deb file to download. Installing it offers to add the repository and key for you. That is convenient, but it does the repository setup on your behalf without showing you the steps. This course uses the manual method so that you can see what you have trusted, and it leaves a file (vscode.sources) that Chapter 10 can put in the rebuild script.
Updates now come through apt
Because VS Code was installed from an apt repository, sudo apt update && sudo apt full-upgrade updates it along with everything else, and Chapter 2's routine covers it. Microsoft notes the repository can lag behind a release by up to three hours, so a brand-new version may take a little while to appear. The trade-off of a third-party repository is that you have added one more source of code to your machine, so keep it to the ones you actually need.

Extensions and Settings

VS Code is only as useful as its extensions. You can install them from the command line, which is what makes them recordable:

code --install-extension ms-python.python code --install-extension bmewburn.vscode-intelephense-client code --install-extension dbaeumer.vscode-eslint code --install-extension esbenp.prettier-vscode code --install-extension ms-vscode-remote.remote-ssh code --list-extensions
ExtensionWhy
Python (ms-python.python)Runs and debugs Python, and finds your project's virtual environment from Chapter 5.
PHP Intelephense (bmewburn.vscode-intelephense-client)Code completion and error hints for PHP.
ESLint and PrettierChecks and formats JavaScript, the tools you would install per project with npm from Chapter 6.
Remote - SSH (ms-vscode-remote.remote-ssh)Opens a folder on another machine, such as debserver, over the SSH connection from Chapter 2.

Confirm each identifier in the extension marketplace before installing, because publishers rename things and this list is a starting point, not a guarantee. If a command reports that an extension was not found, search for it in VS Code's Extensions panel and copy the identifier from there.

Extensions can read your code
An extension runs with your permissions and can see your files. Install extensions from publishers you recognise, prefer ones with many users, and remove any you do not use. VS Code also sends usage data to Microsoft by default. If you would rather it did not, set "telemetry.telemetryLevel": "off" in your settings file, or search “telemetry” in the Settings screen.

Recording the list

Save the list now, and you can rebuild this part of the machine with one command later:

# Save code --list-extensions > ~/vscode-extensions.txt # Restore on a fresh machine xargs -L1 code --install-extension < ~/vscode-extensions.txt

Choosing a Default Editor

Several programs, Git among them, open “the editor” when they need input from you. If that is not the editor you want, you will meet an unfamiliar interface at an awkward moment. Set it once. Debian keeps a system-wide choice, and you can override it for yourself:

# System-wide default (asks you to pick from installed editors) sudo update-alternatives --config editor # Just for your own account select-editor # Belt and braces: name it in your shell, and tell Git directly echo 'export EDITOR=vim' >> ~/.bashrc git config --global core.editor "vim"

Choose the editor you are most comfortable with in a terminal. If that is nano, use nano; the point is that it is a decision you made, not one that surprised you. Check it with git config --global --get core.editor and echo $EDITOR. If you would rather use VS Code for Git messages, git config --global core.editor "code --wait" works; the --wait makes Git pause until you close the file.

Which Tool for Which Job

You want to…Use
Work on a projectVS Code, with a few well-chosen extensions
Edit a config file, or work over SSHVim, Neovim or nano
Edit files on debserver from VS CodeRemote - SSH
Keep VS Code updatedapt full-upgrade
Rebuild your editor setupvscode.sources and vscode-extensions.txt

Hands-On Exercises

Exercise 1

Add Microsoft's repository and install VS Code by the manual method. Before installing, inspect the key you downloaded. After installing, use the Chapter 3 tools to prove where the package came from. Explain what the Signed-By line does and what you have trusted.

๐Ÿ“„ View solution
Exercise 2

Set your default editor at every level (system, user, shell and Git), then prove each setting took effect. Trigger Git's editor with a test commit and confirm the right editor opens.

๐Ÿ“„ View solution
Exercise 3

Install three VS Code extensions from the command line, save the list, remove one extension, and restore it from the saved file. Then describe how you would use Remote - SSH to edit a file on debserver, and one risk of doing so.

๐Ÿ“„ View solution

Chapter 8 Quick Reference

  • Debian 13 has Vim 9.1, Neovim 0.10.4 and nano; VS Code is not in Debian and comes from Microsoft's repository
  • Key: wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg; inspect with gpg --show-keys
  • Repository file /etc/apt/sources.list.d/vscode.sources with Signed-By: /usr/share/keyrings/microsoft.gpg
  • sudo apt update && sudo apt install code; afterwards apt full-upgrade keeps it current (repository can lag up to three hours)
  • A third-party repository means trusting that publisher; keep them to the ones you need
  • Extensions: code --install-extension ID, code --list-extensions; verify IDs in the marketplace
  • Save and restore: code --list-extensions > file; xargs -L1 code --install-extension < file
  • Default editor: sudo update-alternatives --config editor, select-editor, EDITOR, git config --global core.editor
  • Remote - SSH edits files on another machine over SSH; be careful when the machine is debserver