Comments (6)
I would guess an implementation based on search()
rather than a :substitute
command would have a lot fewer side-effects, if we're not stuck w/ this approach for performance reasons or something. @rburny have we already looked into using search()
?
from vim-searchindex.
@dbarnett Yes, initially I had the same idea as you. A while
loop invoking search()
which increments a counter (with a guard to avoid being stuck in an infinite one). Unfortunately, in my limited testing, it seemed that :substitute
was sometimes much faster than search()
. Maybe I made a mistake, or maybe I just had bad luck with some particular patterns though.
But if search()
can, indeed, be much slower than :substitute
, I prefer using the latter, because I value the speed of the plugin more than the lost flags/metacharacters, as I almost never use them.
Also, there are a few workarounds to the possible slowness of search()
, including the 4
th optional argument {timeout}
.
from vim-searchindex.
Alright cool, sounds like you've investigated in way more depth than I have. =)
So it sounds like the best path forward is to add the two improvements you mentioned along with some comments about why search()
isn't an option for the benefit of anyone trying to improve it in the future.
from vim-searchindex.
Thanks for investigating these!
Indeed, I have used :s
command because it is much faster. In contrast, any solution that implements a loop in Vimscript (like search()
loop) tends to be slow, especially on large files.
I agree with your assessment - let's fix what we can within the current solution. Pull requests are welcome :)
from vim-searchindex.
One side effect of silent! execute a:range . 's///en' . gflag
is that it changes the last substitute string.
For example:
:s/red/blue
/green (press enter here invokes <Plug>SearchIndex which sets the last substitute string to ''
:~
Without the plugin, the last :~
will replace green
with blue
. With the plugin, it will replace green
with empty string.
The case can be fixed by changing the above mentioned line to
silent! execute a:range . 's//~/en' . gflag
A PR #20 is created for this.
from vim-searchindex.
The side effect of changing the last used flags is not addressed.
from vim-searchindex.
Related Issues (20)
- Count of total matches is incorrect when cpo-c is not present HOT 3
- it does work in vim, but does not work in mccvim HOT 1
- Broken in MacVim HOT 2
- Feature request - Add an option not to jump to prev/next instance HOT 4
- Vim debug mode could not work HOT 3
- Change search voice under the cursor HOT 2
- incompatible with https://github.com/haya14busa/vim-asterisk HOT 2
- The plugin does not seem to respect 'shortmess+=c' HOT 1
- Issues with case-insensitive search HOT 4
- Plugin ignores T flag of shortmess option HOT 1
- Awkward wording in README
- "Press ENTER" when `nowrapscan` is set HOT 3
- Moving to match hide counter
- searchindex does not show immediately after do searching under highlight
- Allow for centering after a search. HOT 1
- Show number of matches on the fly HOT 2
- Command to disable/enable searchindex functionality HOT 2
- Exchange the position of index and pattern HOT 6
- Search index not shown when first complete a search with incsearch.vim HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-searchindex.