Skip to main content

Helix Editor Cheatsheet


Helix Editor Cheatsheet

Deleting Text:

  • Delete a Word: Useful when you need to remove a word quickly.
    • wd
  • Delete a Character: Efficient for removing individual characters.
    • d or ;d (; reduces the selection to a single char.)

Changing Text:

  • Change a Word: Ideal for substituting one word for another.
    • ec or wc (includes the whitespace after the word)

Copying Text:

  • Copy a Line: Handy for duplicating lines.
    • xy

Global Replace:

  • Replace All Occurrences: Useful for global text replacements within the entire buffer.
    • %sword<ret>creplacement<esc>
  • Go to Last Line: Useful to quickly navigate to the end of the file.
    • ge
  • Go to Line Start: Handy for moving to the beginning of a line.
    • gh
  • Go to First Non-blank Character: Ideal for skipping leading whitespace.
    • gs
  • Go to Line End: Useful to quickly navigate to the end of a line.
    • gl

Deleting to Line End:

  • Delete to Line End: Useful for quickly deleting text from the cursor to the end of the line.
    • vgld or t<ret>d

Jump to Matching Bracket:

  • Jump to Matching Bracket: Helpful in code navigation, especially in nested block structures.
    • mm

Auto Complete:

  • Auto Complete: Assists in completing words or phrases.
    • C-x

Comment Lines:

  • Comment Lines: Essential for quickly commenting out code lines.
    • C-c

Search for Word Under Cursor:

  • Search for Word: Enables quick search for other occurrences of the word under the cursor.
    • A-o*n (with LSP) or be*n

Block Selection (Multiple Cursors):

  • Block Selection: Facilitates editing at multiple positions simultaneously.
    • Use C to add new cursors on the line below, and standard movements for horizontal selection.

Search and Replace in Current Selection:

  • Search and Replace: Useful for batch replacements within a specified region of text.
    • sfoo<ret>cbar<esc>

Select Whole File:

  • Select Whole File: Handy for operations affecting the entire file.
    • %

Reload File from Disk:

  • Reload File: Helpful when the file has been modified outside of Helix and you want to load the latest version.
    • :reload<ret> (or :reload-all<ret> to reload all the buffers)

Run Shell Command:

  • Run Shell Command: Allows for executing shell commands without leaving the editor.
    • :sh command

Setting a Bookmark (Jumplist):

  • Setting a Bookmark: Useful for marking important positions in the text for easy return later.
    • C-s: Save a location in the jumplist, then use <space>-j to open the jumplist picker, C-o to go back in the jumplist, and C-i to go forward.

Additional Selection Commands:

  • Select Current Line: Handy for quickly selecting the entire current line.
    • yy
  • Select Inside Characters: Useful for selecting text within surrounding characters.
    • i<char>
  • Select Around Characters: Useful for selecting text and surrounding characters.
    • a<char>

Other Useful Commands:

  • Open File: Useful for quickly opening files without leaving the editor.
    • :open <filename>
  • Save File: Handy for saving changes.
    • :w
  • Save and Quit: Useful for saving changes and exiting the editor in one command.
    • :wq
  • Quit Without Saving: Ideal for exiting without saving changes.
    • :q!

Multi-line Editing:

  • Join Lines: Useful for merging multiple lines into a single line.
    • J
  • Split Lines: Handy for splitting a long line into multiple lines.
    • gS

Helix Editor Cheatsheet - Page 2

Line Manipulation:

  • Move Line Up: Handy for rearranging lines of code or text.
    • alt+k
  • Move Line Down: Useful for moving lines down in your file.
    • alt+j

Indentation:

  • Increase Indent: Ideal for adhering to coding style guidelines.
    • >
  • Decrease Indent: Useful for dedenting lines of code.
    • <

Undo and Redo:

  • Undo: Essential for reverting unwanted changes.
    • u
  • Redo: Handy for reapplying changes after an undo.
    • ctrl+r

Finding and Replacing:

  • Find Next: Useful for iterative searching in your document.
    • n
  • Find Previous: Handy for searching backwards in your document.
    • N
  • Replace All Instances in File: Efficient for global text substitution.
    • :replace <old> <new>

File Navigation:

  • Go to File Beginning: Quick navigation to the start of the file.
    • gg
  • Go to File End: Quick navigation to the end of the file.
    • G
  • Go to Specific Line Number: Efficient navigation to a particular line.
    • :<line_number>

Buffer Management:

  • Open New Buffer: Useful for working on multiple files.
    • :new
  • Switch Buffer: Efficient for navigating between open buffers.
    • :buffer <buffer_number_or_name>
  • List Buffers: Handy for viewing all open buffers.
    • :ls

Window Splitting:

  • Split Window Horizontally: Useful for viewing files side-by-side.
    • :split
  • Split Window Vertically: Ideal for viewing files above and below each other.
    • :vsplit

Code Folding:

  • Fold Code: Essential for hiding blocks of code to improve readability.
    • zf
  • Unfold Code: Useful for expanding folded sections of code.
    • zo
  • Toggle Fold: Handy for quickly toggling the folded state of code blocks.
    • za

Themes and Appearance:

  • Set Theme: Personalize the appearance of the editor.
    • :theme <theme_name>
  • Set Font Size: Customize the font size for better readability.
    • :set font_size=<size>

Help and Documentation:

  • Access Helix Help: Essential for learning more about Helix commands and features.
    • :help
  • View Command Documentation: Ideal for understanding specific commands.
    • :help <command_name>

Helix Editor Cheatsheet - Page 3 (Advanced)

Macro Recording and Playback:

  • Start Macro Recording: Useful for automating repetitive tasks.
    • qa (where a is the register to store the macro)
  • Stop Macro Recording: Stop recording actions.
    • q
  • Play Macro: Execute recorded actions.
    • @a (where a is the register the macro is stored in)

Advanced Selection:

  • Expand Selection to Syntax Node: Useful for language-aware selection expansion.
    • A-o
  • Shrink Selection to Syntax Node: Handy for narrowing down the selection.
    • A-i

Regular Expressions:

  • Search using Regex: Powerful search using regular expression patterns.
    • /regex_pattern
  • Global Search and Replace using Regex: Efficient for complex text substitutions across the file.
    • :%s/regex/replacement/g

Custom Commands:

  • Define Custom Command: Tailor Helix to your workflow by creating custom commands.
    • :command name command_definition
  • Execute Custom Command: Run your custom command.
    • :name

External Command Interaction:

  • Pipe Selection to External Command: Process text with external shell commands.
    • :w !command
  • Read Output of External Command into Buffer: Insert output of an external command.
    • :r !command

Language Server Protocol (LSP) Integration:

  • Start LSP Server: Enhance coding with language-specific features.
    • :lsp-start
  • Stop LSP Server: Stop the LSP server when done.
    • :lsp-stop
  • Show LSP Server Status: View the status and capabilities of the connected LSP server.
    • :lsp-status

Advanced Configuration:

  • Open Configuration File: Customize Helix's behavior by modifying the configuration file.
    • :e ~/.config/helix/helixrc.toml
  • Reload Configuration: Apply changes made to the configuration file.
    • :reload

Debugging:

  • Toggle Debug Mode: Useful for troubleshooting issues within Helix.
    • :debug
  • View Log File: Access logs for deeper insight into Helix's operation.
    • :e ~/.cache/helix/helix.log

Plugin Management:

  • Install Plugin: Extend Helix's functionality with plugins.
    • :plug-install plugin_name
  • Update Plugin: Keep plugins up to date.
    • :plug-update
  • Remove Plugin: Remove unwanted plugins.
    • :plug-remove plugin_name

Online Resources:

  • Helix Community Discussions: Engage with the community for advanced tips and tricks.
  • Helix Documentation: Deep dive into Helix's documentation for advanced usage.