Some time ago, I was using Sublime Text Editor for my programming work. For a very long time, I was satisfied with this text editor. But after some time, Sublime Text didn’t fit me as well as at the beginning anymore. So, I started research on something new. I found Visual Studio Code - free, built on an open-source text editor. Today, I will tell you more about this tool.
Why I don’t use Sublime Text anymore?
As I told you in the beginning, I liked Sublime Text. But after some time, when my projects started to grow and everything was running in the Docker containers, something changed. I notice one small thing, which irritates me a lot. From time to time Sublime Text just freeze. I was not able to do anything. Because the situation was repeating over and over again, even more often and this freezing completely crashed my flow, I decided to search for something new. Something that can handle my project without freezing. I found the Visual Studio Code.
What I like about VS Code?
When I was looking for a new tool, a new text editor, I search for something like Sublime Text. I wanted to have similar functionality, but faster than Sublime Text. Visual Studio Code is exactly that kind of tool. Let’s check it:
I can split my editor to as many panels as I need - this is a pretty cool feature. For me, two panels at the same time are enough. One is for code and one is for tests. This gives me the boost of productivity in my TDD flow.
VS Code in command line - VS Code has its command-line interface (CLI), which allows you to customize how the editor is launched. You can have different VS Code workspaces prepared for different folders. Each time you work on a specific project, you have setups adjusted to what you do (open files, chosen language, explorer sidebar). This is something that allows me to save me time when I switch between projects. My favourites commands are:
code .
- open code with current directorycode --diff <file1> <file2>
- open diff editorcode --goto package.json:10:5
- open file at specific line and column<file:line[:character]>
Everything is customizable - if you want to change your settings just use
Ctrl + ,
you will see commonly used settings in one place. You can adjust them to a specific workspace or for your user.Adding new extensions - VS Code has many functionalities built in. Like Emmet, Terminal, Debugger, or Git usage. But if you need something more, you can always search for an extension. Those are some of my extensions:
- Code Spell Checker - A basic spell checker that works well with camelCase code.
- Spell Right - Multiple languages spell checker.
- GitLens - Git supercharged - Additional support for git in VS Code. For example, show git history in line.
- JSON Tools - Tools to manipulate JSON. You can pretty/minify JSON with this extension.
- Markdown Preview Enhanced - Allow you to see a preview of your markdown files in real-time.
- ruby-rubocop - Rubocop linter for VS Code. This is a linter for Ruby programming language.
- Slim - Support for Slim.
- Sort lines - Extension for sorting lines.
Keyboard Shortcuts - ❤️ I love keyboard shortcuts. They allow me to focus on what I’m doing and completely forget about how to do it. I don’t need to go back and forward from the keyboard to the mouse. I can do my flow. Before I will go to some of the shortcuts, I would like to mention two more things. First, keymaps. If you get used to shortcuts from another text editor, you can install a Keymap, which brings you all your favourite shortcuts to VS Code. Second, you can customize your keyboard shortcuts by using
Ctrl + K Ctrl + S
.
Keyboard shortcuts list
I decided to learn default VS Code shortcuts. Here are my favourites:
Managing workspaces, panels and sidebars
Ctrl + B
- toggle sidebar (you can find there explorer, searchbox or extensions sidebar)Ctrl + Shift + X
- search for new extensions and list of installed extensionsCtrl + Shift + E
- show Explorer with list of your files and foldersCrtl + J
- toggle panel (you can find there problems, terminal, output or debug console panel)Ctrl + Shift + M
- shows panel with errors and warnings available for current contextF8
- go to next error (when errors panel is open)Shift + F8
- go to previous error (when errors panel is open)Ctrl + `
- integrated TerminalCtrl + 0
- focus on sidebar (you can use arrows to navigate between folders and files, pressenter ↩
to open selected file and move the focus to this file)Ctrl + 1,2,3,4
- move focus between open panels/groups (it depends layout you choose)Ctrl + PgUp, PgDn
- go to previous/next open tab/fileCtrl + Shift + T
- open last closed tab (just like in your browser)Ctrl + \
- split one workspace to side by side editionCtrl + N
- open new tab/fileCtrl + O
- open existing fileCtrl + Shift + N
- open new workspace/windowCtrl + W
- close current file/tabCtrl + K Ctrl + ←
- focus into previous editor groupCtrl + K Ctrl + →
- focus into next editor groupCtrl + Shift + PgUp
- move editor leftCtrl + Shift + PgDn
- move editor rightCtrl + K ←, →
- move active editor group left/rightCtrl + K ↑, ↓
- move active editor group top/bottom
Navigation
Ctrl + G
- go to line in current fileCtrl + R
- navigate between recently opened folders and workspacesCtrl + P
- quick-open files by name in your project (you can even search by first letters of each part of file name example: searching bymnf
, and VS Code will findmy_new_file.txt
), when you use→
you can open multiple filesCtrl + T
- go to Symbol the in workspaceCtrl + Shift + O
- go to Symbol in File, you can group the symbols by kind by adding a colon,@:
History navigation
Ctrl + Tab
- navigate entire history, choose next file from current panelCtrl + Shift + Tab
- navigate entire history, choose previous file from current panelCtrl + Alt + -
- navigate backCtrl + Shift + -
- navigate forward
JSON
Ctrl + Alt + M
- pretty JSON power by JSON ToolsAlt + M
- minify JSON power by JSON ToolsCtrl + Shift + I
- pretty JSON included directly in VS Code, to use this JSON formatting you need to set JSON file extension or select JSON language mode
Markdown (Markdown Preview Enhanced extension)
Ctrl + Shift + V
- open Markdown previewCtrl + K V
- open side by side Markdown edit and previewCtrl + Shift + S
- sync preview / sync source
Multi lines cursor
Shift + Alt + ↑, ↓
- add cursor to line above or below current lineCtrl + Shift + ↑, ↓
- add cursor to line above or below current lineCtrl + Shift + L
- add additional cursors to all occurrences of the current selectionCtrl + U
- undo last cursor operationShift + Alt + I
- insert cursor at end of each selected lineCtrl + ←, →
- go to word beginning/ending
Multi selection
Ctrl + D
- select word (repeat selection of others occurrences in context for multiple editing)Ctrl + F2
- select all occurrences of current wordCtrl + A
- select a whole fileCtrl + L
- select a whole lineShift + Alt
- select column/box while drag a mouseCtrl + Shift + ←, →
- select previous/next word
Indentation
Ctrl + ]
- indent current line(s)Ctrl + [
- outdent current line(s)Tab
- when cursor is on the beginning of a line indent current line(s)Tab + Shift
- when cursor is on the beginning of a line outdent current line(s)Ctrl + Shift + I
- formatting any file based on language rules
Edition tricks
F9
- do alphabetical order of selected lines power by Sort linesAlt + ↑, ↓
- move line up and downCtrl + ↩
- insert line afterCtrl + Shift + D
- duplicate line(s), (this is shortcut I added to my VS Code), when you use operation system different then Ubuntu you should be able to use default VS Code keyboard shortcutCtrl + Shift + Alt + ↑, ↓
, on Ubuntu this is Ubuntu shortcut for moving windows between virtual desktopsCtrl + C
- copy selected text to clipboard or when you have cursor in line without selected text copy whole line to clipboardCtrl + V
- paste selected text or whole line from clipboardCtrl + X
- cut selected text or whole line (when text is not selected) to clipboardCtrl + Z
- undo your last changeCtrl + Shift + Z
- redo your last changeCtrl + Y
- redo your last changeCtrl + Backspace
- remove previous word (without adding to clipboard)Ctrl + Delete
- remove next word (without adding to clipboard)Ctrl + Shift + K
- delete line (without adding to clipboard)Ctrl + K Ctrl + X
- trim trailing whitespaces
Code tricks
Crtl + /
- comment/un-comment line (it depends selected programming language)Ctrl + K Ctrl + L
- open/close selected section in codeCtrl + Shift + \
- jump to matching bracket
Search & Replace
Ctrl + F
- search in the current fileF3
- next searched phraseF3 + Shift
- previous searched phraseCtrl + H
- replace one phrase to another in the current fileCtrl + Shift + F
- search in whole workspaceCtrl + Shift + H
- replace one phrase to another in whole workspace
Others
Ctrl + ↑,↓
- move file up/down by one line (like scroll)Ctrl + S
- save fileCtrl + K M
- change programming language modeCtrl + K P
- copy path of active fileF2
- rename Symbol (file name, class name, method name)Ctrl + Shift + P
- Command Palette, access to all available commands based on your current context
Need help?
If you're looking for a Ruby developer with over a decade of experience, don't hesitate to contact me.
I have experience in a variety of domains, with a focus on short user feedback loops and teamwork. I can help you build a great product.