Open cuixiaorui opened 1 year ago
Good, I need it!
great!
Would you create a pull request once you have done?
Would it be feasible to add the feature to only match beginning of words, please? Or could you recommend a Flash-like VS Code extension that supports that?
Match beginning of words only
require("flash").jump({
search = {
mode = function(str)
return "\\<" .. str
end,
},
})
Fwiw the real flash.nvim is supported with vscode-neovim.
Thank you very much! flash has to be the best plug-in by FAR
Just wanted to say thank you for this amazing work @cuixiaorui 👏
Great work @cuixiaorui !
I think, it deserves a merge of this feature.
Perhaps, keep default key to s
to don't change to much user habit (user can stil remap if he wants).;
Hi, guys.
I have to say that flash.nvim is better than leap.nvim.
So I've implemented something similar to flash.nvim in vscodeVim.
So far it's done.
and I can't live without it in my daily work.
Here is a description of the flash plugin and how to install it.
If you have more ideas, please feel free to contact me.
Functions
Let's take a look at what flash can do
The basics
The most basic way to use flash is:
f
+ the character to search for + the marker labelFor example, if you want to search for "vscode"
Just press
f
+ "vscode" and you'll see lots of labels highlighted in green on the screen.These labels are markers, and you can jump to them by pressing the corresponding label character.
Isn't it very simple?
Compared to leap, flash doesn't limit the number of characters you can input.
It's the same as /search, so it feels very natural.
At the same time, because of the label, it is much more efficient than / search.
There's a limit to the number of labels you can jump to.
It's important to note that there is a limit to the number of labels that can be used.
By default, there are only these 'hklyuiopnm,qwertzxcvbasdgjf;'
When matching, it also removes the next possible character to be entered
so the actual label is smaller.
When the number of matching characters is greater than the number of labels, the label is not displayed.
The solution is also very simple, just type in a few more characters, like this.
Supports displaying the currently typed search character in the statusBar.
For consistency with /search the currently typed characters will be displayed during the search.
If you type a wrong character quickly, there will be no match at all.
You can check for spelling errors by looking at the characters displayed in the statusBar.
Support for logging jump points
After a flash jump, it will be recorded in the jump list.
So this means that you can jump back to the previous position with ctrl + o/i.
This is very useful when writing code in everyday life, for example in this scenario.
You're writing code in a, and then you want to copy the code in b.
You can use f to jump to the location of the code you want to copy.
Then press
ctrl
+o
to go back to a and paste the code, and then continue coding.Support for visualization mode
Flash can also be used in visual mode.
Just press v and then
f
+ the character you're searching for.Operator support
flash also supports operators.
Now you can use it with the operators
d
ory
It will contain the entire searched character, i.e. it will work up to the end of the searched character.
PS: this is a big breakthrough after leap!
The previous implementation of leap didn't support the operator
Support for carriage returns to jump to the next marker.
When you want to jump to the next marker directly
you can just press
enter
.There is also a different background color for the next marker.
Support for last search
Sometimes I want to search for the last search character, but I'm too lazy to repeat it.
What can I do?
Well, flash takes care of that for you.
Just hit
f
+enter
and that's it!The last search history is recorded after a successful challenge.
If no previous search exists, you'll be prompted.
These are the functions supported so far
Compared to flash.nvim, there are not many functions, but they are all basic functions that are frequently used in daily life.
The main focus is on utility.
Configuration
Let's talk about the currently supported configurations
ignores case
Default is true
Match both upper and lower-case characters
If set to false it is case sensitive
sets labels
The label that is displayed at the point of the marker.
You can expand it as much as you want.
Note that it only displays one character at a time.
For those of you familiar with easymotion, you can see that these are easymotion labels.
Yes, I took the label from easymotion, because I'm lazy.
sets the background color of the label
Set the background color of the marker
The default color is the same as leap, which I like.
If you think it's ugly, feel free to change it.
sets the background color of the next match.
Set the background color of the next marker
This color is a reference to flash.nvim, which made up an orange color that looks pretty good.
Installation
Now all you need to do to use flash is the following:
Now you can happily use flash!
Why CVim?
The last leap was to let you download the installer directly, but a lot of students said it was too much trouble.
But a lot of students said it was too much trouble, and they wondered if they could install it directly from the plugin market.
So this time, flash will fulfill your request.
released a plugin for CVim.
It's the official Vim version with flash functionality.
I'll be updating CVim from time to time to synchronize with official updates.
Luckily, VScodeVim is very stable now, and updates are very infrequent, so the maintenance cost is not that big.
Of course, it would be nice if they could merge my code, but that's not really an option for features like this.
Because it will affect many old users, and not every old user wants to use flash.
So there's no need to wait for the official announcement, let's use the new features first.
I'll post some good plugins to CVim later.
I'll let the new features settle in CVim first, and then submit PR to Vim when it's really well accepted.
Why use f as the on key?
There are two questions you might have about using f as an opener:
What about the native f function?
Some of you may be worried about what to do with the native f function when you use f as the on button.
Actually, the flash function can completely replace the native f function now.
The matching algorithm of flash is based on matching the current line up and down.
This guarantees that the current line will have a marker.
So searching based on a single character can also jump to the!
This can also be combined with a carriage return to jump directly to the first matching token.
So compared to the native f, there are only two cases.
enter
one more time.Why don't you use s anymore?
I've given up on the
s
key for three reasons.The
s
key is very useful.The
s
key is actually a very common and very useful operator.If you don't use
s
, you have to usedl
instead.The reason why sneak and leap used s
I suspect that the reason why sneak and leap used the s key is that it's not an alternative to the f key.
conflicts with the vim-surround plugin.
Using
s
in vscodeVim will conflict with the vim-surround plug-inYou can see that surround can also be used in conjunction with the
y
d
c
s
operatorPressing
f
is more comfortable than pressings
Pressing
f
is more comfortable than pressings
. Pressingf
uses the index finger while pressings
uses the ring finger. So the index finger must be more comfortable.Problem
There's no caching optimization for the display of jump points.
But it's pretty smooth in use so far, so it's tolerable.
We'll deal with it later when we go live.
We haven't found any other problems yet.
If you have any problems with it, please leave me a message or add me on wechat: cuixr1314
Compare flash.nvim
flash.nvim contains a lot of features, and I've only implemented the basics.
But I think these basic features are enough for me.
Here's a list of some of the features
For those of you who are used to using flash.nvim, it's important to know that
f
instead ofs
.ctrl
+o
to operate.Open Source
The code is here. Feel free to contribute code.
The implementation principle is quite simple, so you can see the source code directly. ~~~~