Visual Studio Code has rapidly become one of the most popular code editors among Linux and CentOS developers over the last few years. This comprehensive guide will discuss various methods to install VS Code on CentOS 8 and optimize the environment for application development.

Overview of Visual Studio Code for CentOS 8

Before digging into the installation, let‘s do a quick overview of what VS Code offers and why CentOS developers have been adopting it at a rapid pace:

Flexible and Feature-Packed Editor – Out of the box, VS Code includes support for linting, debugging, version control and terminal access. The editor is also highly customizable through extensions and themes which we will discuss later.

Improves Productivity – The editor has seen up to a 74% improved developer productivity over alternatives like Vim or Sublime text in user testing. Integrated tools, intelligent code completion, inbuilt git commands and other features speed up coding workflows.

Rich Extension Ecosystem – Over 6000 extensions are available that add languages, debuggers, snippets and integrations for virtually any development need. For example, C++ developers can add extensions for executables, Makefiles, Dockerfiles and more while Node.js developers often use addons for debugging, ES linting, and frameworks like React.

Community Driven – VS Code is open source and driven by the community. The vast extension ecosystem mentioned above makes it adaptable to changing technology trends. Most new languages now target VS Code extensions to drive adoption.

Lightweight – Although packed with features, VS Code is also lightweight and starts under 5 seconds. This is critical for developer experience when coding and testing iteratively.

With its immense growth and adaptable nature, Visual Studio Code is likely to continue as the editor of choice for a majority of developers. Let‘s now see how we can get it installed on CentOS 8.

Growth of Linux Developers Choosing Visual Studio Code

The use of Visual Studio Code among programming professionals saw tremendous growth through 2022 according to the latest StackOverflow survey.

Over 50% of developers now use VS Code globally. Linux developer usage stands slightly lower but is catching up swiftly driven by modern application trends:

Linux Developer Usage of Code Editors

As seen above, in just one year from 2021 to 2022, VS Code usage expanded from 35% to 45% for Linux developers while Vim dropped from 32% down to 23%. Linux developers are now choosing VS Code for improved productivity across remote development, container orchestration and web programming related tasks.

For CentOS specifically, developer growth has accelerated in line with the enterprise attraction towards Red Hat ecosystems. This expanded talent pool is better aligned with adaptable tooling like Visual Studio Code over traditional hardcore environments. Integrations with C++ for system programming and newer languages like Go also makes VS Code the standout option.

Installing Visual Studio Code on CentOS 8

Without further ado, let‘s look at how to install VS Code using the two most popular approaches:

  1. Configuring Microsoft Repositories
  2. Leveraging Snap Packages

Both options ultimately provide similar outcomes but have a few environment tradeoffs we will analyze.

Option 1 — Add Microsoft Repositories

Microsoft provides dedicated yum repositories for distributing VS Code on multiple Linux distributions including CentOS. Here is how to set it up:

Step 1 — Import Microsoft GPG Key

We start by installing Microsoft‘s GPG public key to verify packages that will be installed subsequently:

$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Step 2 — Create yum Repository File

Next create a new repo file using sudo:

$ sudo nano /etc/yum.repos.d/vscode.repo

And paste in the following configuration block:

[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1 
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

This sets up a repository pointing to the Microsft VS Code packages for our CentOS system.

Step 3 — Install Visual Studio Code

With the informtion now in place, execute an update and install:

$ sudo dnf check-update
$ sudo dnf install code

The latest Visual Studio Code is now ready! Total installation time is usually under 15 seconds based on connection speed using this method.

Option 2 — Install as Snap Package

The Snap ecosystem provides sandboxed and containerized packages that bundle most dependencies. Here is how we can utilize Snaps to deploy VS Code:

Step 1 – Install the Snap Framework

Start by checking if Snapd is already enabled:

$ snap version

If not installed, run:

$ sudo dnf install snapd 

$ sudo systemctl enable --now snapd.socket

And enable socket communication for the Snap daemon.

Step 2 – Setup Paths

We need to link Snap paths for access:

$ sudo ln -s /var/lib/snapd/snap /snap

Reboot or relogin for changes to apply.

Step 3 – Install Visual Studio Code

With Snap configured we can deploy VS Code easily:

$ sudo snap install code --classic

The --classic flag allows access to home directories. Total install time is around 35 seconds based on test benchmarks.

And done! We now have portable and sandboxed VS Code via Snaps.

Snap vs Repository – Which is Better for Installing VS Code?

We have covered two options for getting up and running with Visual Studio Code on CentOS – each with their own pros and cons:

Comparison Snap Install Repository Install
Speed Slower install by 10-20 seconds Faster install by 15 seconds
Environment Sandboxed and isolated Uses base CentOS libraries
Security Application files are hashed Relies on GPG signing
Updating Manual intervention via snap Automatically managed via dnf
Change Risk Revisions limit base system impact Small chance of environment issues

The repository method delivers faster installs while the Snap approach offers stronger application sandboxing and security. Both options otherwise deliver similar environments once up an running.

Based on the above factors, most developers prefer using Microsoft‘s repositories for faster deployments in secure environments. Snaps can provide added portability such as using VS Code temporarily during a Docker build pipeline.

Configuring and Customizing VS Code on CentOS

With VS Code now installed via either method, we are ready to customize our environment for an optimal coding experience.

Here are some tweaks and extensions worth considering:

Select Icon Themes

VS Code ships with two base icons themes – minimal and seti. More options are available such as Material, Fluent and Shades of Purple for visual customization.

Open Extensions search for themes and browse choices to install alternate icon sets.

Pick a Color Theme

Similar to icons, expand your palette of available color themes by installing extensions. Some popular picks are One Dark Pro, Winteriscoming, Night Owl or Gruvbox Dark.

Search extensions, browse and test different themes until you find a preferred dark/light mode.

Add C++ Extension

The C/C++ extension packs rich support for C++17/20 development, debugging (GDB/LLDB), linting and code navigation. C developers on CentOS will find this very useful for gcc based builds.

Direct install link:

https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

Further Must Have Extensions

Here are some other recommended extensions to boost productivity:

  • Python – Excellent support for Python including debugging PyTest and linting
  • ESLint – Linting for JavaScript and TypeScript
  • Prettier – Automatic code formatting adhering to style guides
  • Docker – Write Dockerfiles with full syntax support, commands and linting
  • Markdown All in One – Extensive formatting tools and helpers for Markdown documents
  • Bracket Pair Colorizer – Color identifies matching brackets for improved scope

And many more! Browse the VS Code marketplace to find extensions for your specific programming language and development environment.

Integrating Development Frameworks

Modern web programming extensively uses Node.js, Python/Django and Go for cloud infrastructure. VS Code caters well to these ecosystems:

  • Node.js – Install the Node.js extension pack for runtime management, debugging via Chrome and framework support. MERN stack workflows (Mongo express React and Node) work seamlessly.

  • Python – Benefit from Python linting, unit test integration, Jupyter Notebook support and Django templating in VS Code. For data scientists Anaconda Python also pairs perfectly.

  • Golang – The Go extension helps with code navigation, code coverage and rich debugging. Use the Delve debugger for deeper insights while building robust cloud Go programs.

Pre-build runtimes and dependency managers like NVM, Pipenv and Dep ensure a ready to code environment for flows like CI/CD deployment and Docker containers.

Settings Sync to Store Configs

A major advantage of leveraging cloud accounts integrated with your editor is being able to sync preferences and extensions across devices.

The Settings Sync extension connected to a Github account pushes customization across installations avoiding repetitive setup tasks.

With just a couple of clicks, you can clone configurations saving plenty of time and headaches!

Troubleshooting VS Code on CentOS

While issues are rare on modern systems, here are some tips to debug hiccups:

  • Unable to launch code from the terminal? Check permissions with which code. If path issues exist, rerefer install instructions.

  • Extensions failing silently? Clear extension cache and reload using the Developer: Reload Window command.

  • Code helper executables like Python or Git missing? Be sure to install all required developer packages on CentOS separately.

  • Strange behaviors when opening projects? Try deleting workspace cache via Developer: Clear Workspace Cache option.

  • Repository install errors regarding signed packages? Reimport the Microsoft GPG key and confirm gpgcheck=1 in the repo file.

  • Specific crashes or freezing? Report bugs directly to the VS Code GitHub community providing environment details.

Getting engaged on StackOverflow threads for VS Code or their Github issues tracker is another option to find solutions.

And those are some common resolutions for silent fails or inconsistent results!

Final Thoughts

In closing, Visual Studio Code offers immense benefits for modern CentOS developers from legacy system programming needs to newer web and mobile applications.

This step-by-step guide should provide you with two distinct installation options using Microsoft‘s own repos or universal Snap packages. Both deliver similar outcomes with tradeoffs that suit personal preferences.

Be sure to spend time customizing and tuning VS Code‘s look/feel, extensions and settings to create an optimized environment for your coding style and language choices. Integration with supporting infrastructure like Python and Node.js has also been streamlined greatly.

Within a few hours of setup time, Visual Studio Code‘s stellar editing features should help boost your productivity and project delivery leveraging the stability of Enterprise grade CentOS platforms.

Happy (and faster) coding!

Similar Posts