-
Notifications
You must be signed in to change notification settings - Fork 137
Commands
Hop ships with a lot of Neovim commands already configured for you to use. Commands start with Hop
and can have
variations. It is important to understand that not everything Hop can do is exposed via commands: only the mostly used
commands have an exported Neovim command. Some features might require you to go through the Lua API instead.
To invoke a Hop command, you need to press the : key, type the Hop command, and then press RET to execute the command. For instance, to hop to words in the current buffer:
:HopWord
Hop commands can have variations. A variation is more restricted or more general version of the command without
the variation. For instance, the HopWord
command can have variations allowing to run that command across all visible
buffers (and not only the current one) or on the portion of text before the cursor.
Not all commands will have the same variations, and not all features of Hop are representable via variations. If you do not find what you want in a command variations, it’s likely that the Lua API can still do it.
There are four command variations, with some of them that can be combined:
-
Hop*BC
: runHop*
before the cursor. -
Hop*AC
: runHop*
after the cursor. -
Hop*CurrentLine
: runHop*
on the current line only. -
Hop*MW
: runHop*
across all visible buffers.
You will also find combinations, like:
-
Hop*CurrentLineBC
: runHop*
both before the cursor and on the current line only. -
Hop*CurrentLineAC
: runHop*
both after the cursor and on the current line only.
As explain in the Command variations section, some commands have variations. Because they all do the same thing, the list of commands here does not include the variation commands (you can deduce what they do by reading the variation section). The total list of commands is then much higher than the list presented here. You get the idea.
The most powerful command and yet probably the less useful, this command will hint everything in the buffer and will allow you to jump to them. Because a lot of items will be hinted, that command will most of the time require you to type several keys before triggering a jump, making that command not so useful to use.
This command prompts you to type one key, and will hint that key in the buffer. This is a very useful command to have mapped to a quick key as it will allow you to jump to special characters, such as characters not part of keywords or words, like punctuation, operators, etc. etc.
Step 1: press a key.
Step 2: press the key sequence to jump to the hint (here, we pressed the . key).
Prompts you for two keys to type and hint the bigram in the buffer. This is also very useful as most of the place you want to jump will be quickly identified by only two keys.
Bonus: if you change your mind and decide to type only one key, you don’t have to abort (with ESC) and use
HopChar1
: instead, just press RET, which will immediately hint the only key you have pressed, yielding the same behavior as ofHopChar1
.
Step 1: press a key.
Step 2: either press another key, or RET to fallback to HopChar1
.
Step 3: press the key sequence to jump to the hint (here, we pressed the lo key sequence).
A pretty useful command, it will hint the first column of each visible line.
Similar to HopLine
, the only difference is that it will hint the first non-whitespace character of each line (similar
to the _
motion).
Very similar to HopLine
and HopLineStart
, the only difference is that HopVertical
will try to keep the cursor
column position as the same as your current cursor.
If a line is shorter than your cursor column position, its end of line will be used as jump target.
A powerful command that mixes the default Neovim search (/
) with hinting. This command will prompt you with any kind
of pattern, that you can validate with RET.
Step 1: enter a pattern and press RET to validate it.
Step 2: press the key sequence to jump to the hint (here, we typed local
as pattern).
Probably the most useful command of all, it will hint all words in your buffer. It is really simple and most of the time will bring your cursor so close to the position you actually want to go to that most of the time, it is easier to jump close to the position rather than the exact position.