Skip to main content
Version: 4.x

Work with source code

ZStudio provides various shortcut and features to help you to work with your source code more productively.

Multiple cursors and selection

When typing, copying, or pasting in ZStudio editor, you can toggle multiple cursors so that your actions apply in several places simultaneously.

A common way to add more cursors is with Ctrl+Alt+Down or Ctrl+Alt+Up that insert cursors below or above, which enable you to select contiguous ranges.

And you can also select multiple non-contiguous text ranges with Alt and click or select.

Add more cursors or selections

Expand or shrink selection

You can realize quick expanding the selection with Shift+Alt+Right and quick shrinking the selection with Shift+Alt+Left .

Expand or shrink selection

Column selection

Place the cursor in one corner and then hold Shift+Alt while dragging the mouse over text ranges (keeping the same keys pressed) realize column selection.

Or you can make column selection by shortcuts Ctrl+Alt+Shift (Alt+Shift in Linux) with Up, Down, Left or Right.

Column selection

Select multiple occurrences

To select multiple occurrences of a word or a text range:

  • Place the caret at an occurrences of the desired word. Successively press Ctrl+D to find and select the next occurrences of matching word or text range.
  • Press Ctrl+Shift+L to add a selection at each occurrence of the current selected world or text range.
Select multiple occurrences

Minimap

A Minimap gives you a high-level overview of your source code, which is useful for quick navigation and code understanding. A file's minimap is shown on the right side of the editor. You can click or drag the shaded area to quickly jump to different sections of your file. You can click Minimap toggle from the view's drop-down menu to turn off it and tell if it is currently on by the toggle-mark-button mark.

ZStudio allows you to quickly find text and replace in the currently opened file or solution.

Find and replace in file

Press Ctrl+F to open the Find Widget in the editor, search results will be highlighted in the editor, overview ruler and minimap.

Select a word or a text range and press Ctrl+Ctrl+F can help you directly search the content you select.

If there are more than one matched result in the current opened file, you can press Enter and Shift+Enter to navigate to next or previous result when the find input box is focused.

Find in selection

By default, the find operations are run on the entire file in the editor. It can also be run on selected text. You can turn this feature on by clicking the hamburger-button button on the Find Widget.

Advanced find and replace options

In addition to find and replace with plain text, the Find Widget also has three advanced search options:

  • Match Case
  • Match Whole Word
  • Regular Expression

You can also use glob pattern syntax , for example:

  • * to match zero or more characters in a path segment
  • ? to match on one character in a path segment
  • ** to match any number of path segments, including none
  • {} to group conditions (for example {**/*.html,**/*.txt} matches all HTML and text files)
  • [] to declare a range of characters to match (example.[0-9] to match on example.0, example.1, ...)
  • [!...] to negate a range of characters to match (example.[!0-9] to match on example.a, example.b, but not example.0)

The replace input box support case preserving, you can turn it on by clicking the Preserve Case (AB) button.

You can search multiple line text by pasting the text into the Find input box and Replace input box. Pressing Ctrl+Enter inserts a new line in the input box.

Search multiple line

While searching long text, the default size of Find Widget might be too small. You can drag the left sash to adjust the Find Widget or double click the left sash to maximize it or shrink it to its default size.

Adjust find widget

Find across files

ZStudio allows you to quickly search over all files in the currently opened solution. Open Search view and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location. Expand a file to see a preview of all of the hits within that file. Then single-click on one of the hits to view it in the editor.

Search and replace

You can also search and replace across files. Expand the Search widget to display the Replace text box.

When you type text into the Replace text box, you will see a diff display of the pending changes. You can replace across all files from the Replace text box, replace all in one file or replace a single change.

Formatting

ZStudio provides C and C++ language support using the clangd and vscode.cpp language server to help you formatting your source code.

To format the entire document:

  • Press Shift+Alt+F on Windows.
  • Press Ctrl+Shift+I on Linux.

To format the selected text:

  • Press Ctrl+Ctrl+F on Windows and Linux.

Along with manually invoking the code formatting, you can also trigger formatting based on user gestures such as typing, saving, or pasting. These are ogg by default but you can enable these behaviors through Settings.

Save and revert

You can always save your changes manually by pressing Ctrl+S.

Auto save

You can turn on or off auto save by clicking File > Auto Save and tell if it is currently on by the toggle-mark-button mark.

Besides, you can also configure actions that will be triggered every time your modified files are saved in Settings.

  • afterDelay: A editor with changes is automatically saved after certain milliseconds delay you set.
  • onFocusChange: A editor with changes is automatically saved when editor loses focus.
  • onWindowChange: A editor with changes is automatically saved when the windows loses focus.

Revert changes

For the most recent changes, you can revert by pressing Ctrl+Z or choosing File > Save All. And for the most robust tracking of all changes, use Source control.

Folding

You can click the folding icons on the gutter between line numbers and line start to collapse or expand blocks of code, hiding code that doesn't need to be displayed, minimizing screen clutter. Move the mouse over the gutter and click to fold and unfold regions or use the following shortcuts to realize quick folding:

  • Fold Ctrl+Shift+[ folds the innermost uncollapsed region at the cursor.
  • Unfold Ctrl+Shift+] unfolds the collapsed region at the cursor.
  • Toggle Fold Ctrl+K Ctrl+L folds or unfolds the region at the cursor.
  • Fold Recursively Ctrl+K Ctrl+[ folds the innermost uncollapsed region at the cursor and all regions inside that region.
  • Unfold Recursively Ctrl+K Ctrl+] unfolds the region at the cursor and all regions inside that region.
  • Fold All Ctrl+K Ctrl+0 folds all regions in the editor.
  • Unfold All Ctrl+K Ctrl+J unfolds all regions in the editor.
  • Fold Level X (Ctrl+K Ctrl+2 for level 2) folds all regions of level X, except the region at the current cursor position.
  • Fold All Block Comments Ctrl+K Ctrl+/ folds all regions that start with a block comment token.
Collapse or expand blocks of code
tip

Go to gear button on the bottom-left corner and choose keyboard Shortcuts to check all the available shortcuts.

IntelliSense

IntelliSense is a general term for various code editing features including: code completion, hover information, errors and warnings, cross reference, and code refactorings, etc. ZStudio provides C and C++ language support using the clangd and vscode.cpp language server to help you code faster and more efficiently.

Code navigation

You can quickly navigate through code in the editor using different actions and popups.

Quick file navigation

To follow a link included in your code or find a file where a code element has been defined, hold Ctrl and click the link or the code element. The file opens in a new tab.

Quick file navigation

Outline

The Outline view informs users of the code structure in the current file. It gives you a tree of the methods, functions, variables, classes, etc. From the right Activity Bar, click the outline-button (Outline button) to open Outline view. Click the elements in the view to navigate through the file. Searching for symbols within current file in Outline is also possible.

<strong>Outline</strong> view

Go to symbol

To perform a focused search of your code and quickly find symbols: right-click anywhere in the editor and select Go to Symbol.....The search bar displays the available symbols in the file you are currently working on. Select a symbol to directly go to it.

Go to symbol

Find definition and reference

You can jump to the definition of a code element under the cursor.

Hover over the code element, right-click and select one of these options:

  • Go to Definition: This option jump to the location where the element is defined. This also works on opening the file where the element is defined in a separate tab.
  • Peek > Peek Definition: This option also takes you to the definition of an element but the definition is presented inline.
Find definition

You can also find the references to a code element throughout all the files within a solution with the Go to References and Peek References options. These two options show the code element references inline (or, if there is only one reference, the Go to References option takes you directly to the element). You can navigate between references and make edits in the inline editor. Double-click a reference to open the file or files where the code element appears. Hover over the code element, right-click and select one of the options.

Find reference

Code completion

According to the content typed by the user in the editors, IntelliSense will analyze the source code and give input suggestions. You can select from pop-up menu and press Tab or Enter to complete your code.

Problems and quick fix

When ZStudio detects problems in your code, it shows diagnostics of compile errors and warnings in-place as red squiggle underlines. All problems will be listed in the Problems view. To open it, click problem-button (Problems view) in status bar or go to the View menu and select Problems.

ZStudio can suggest fixes for common problems automatically, such as a missing semicolon. Hover over an element underlined with a red squiggly line to display corrections. A light bulb icon appears next to the problematic line. Click the light bulb and check the correction suggested to decide whether to apply a correction.

Problems and quick fix

Refactoring

ZStudio supports simple refactorings, including extract variable, extract function, and rename symbol. When you select source code fragments, the lightbulb menu appears and you can choose a code action. Alternatively, you can select the source code you would like to extract and then right-click them and select Refactor...

If you want to rename an element in your code such as a function, a class, or a variable, use the Rename symbol option. This option renames all occurrences of a symbol in the file you are currently working on.

Side by side editing

You can open as many editors as you like side by side vertically and horizontally. If you already have one editor open, there are multiple ways of opening another editor to the side of the existing one:

  • Press Control+\ to split the active editor into two.

  • Click the split-editor-button (Split Editor Right) button in Toolbar.

  • Right click Open Editor to Side on a file from the File Navigation context menu.

  • Right click the Tab of an editor.

  • Drag and drop a file to any side of the editor region.

    Side by side editing

When users open multiple editing areas, they can drag and drop the editing area file title to reposition or resize the editing area.