I am learning helix and as a side effect, I’m becoming more familiar with vim. I write myself notes as I practice different things. So, instead of keeping my notes to myself, thought I’d publish them.
One of the main things that makes helix distinct from vim is the selection-first editing concept. Basically, you select some text and then you apply an action to the selected text.
Select Entire File
% Select whole file
Movements Are Selections
Whenever you are moving the cursor (h,j,k,l, or arrow keys), you are actually moving a one character selection around.
Word Movements
wmove to start of next word.bmove to start of previous wordemove to end of current word
As you move the selection will be marked. This was a little disconcerting at first.
The lowercase version of these commands move to the next space or punctuation mark. The capitalized version of W, B, and E, ignore punctuation marks and move to the next ‘space’.
Match Mode
So, first bit of confusion… how do you select the word you’re sitting on? If you’re sitting in the middle of a word and press w, it moves to the beginning of the next word, but only selects the current word from the character you were sitting on. One simple way is to do press wb or bw to move back and forth. This will select a space at the end. Use be to just select the word without the space.
The other way to accomplish this is to use “match mode”. Pressing m start match mode and opens a pop-up with the available choices. miw will select the current word. maw will select the current word including the space.
Manipulations
s - Enters the select command, which filters within the current selection. then use other commands to make desired changes.
This can leave you with many “cursors”. To collapse those, press ,.
Examples:
Find and delete something in a file.
%swhole <enter>d - Delete all instances of the word “whole” in the file.
The select command can be used to select words, or multiple words by using | (or) between the words.
mip - Select a paragraph.