I can search in the list of entries like this:
How do I proceed to the next match?
Just use usual Arrow Up / Arrow Down keys for navigating between speed search matches.
(just in case) NOTE: Such search is performed on already opened/expanded nodes only -- it will not search in closed nodes or expand them for you.
https://www.jetbrains.com/help/webstorm/2016.3/speed-search-in-the-tool-windows.html
P.S. https://stackoverflow.com/a/24929227/783119
Related
I'm trying to run an index match that returns some text, but I don't want the full text, just the portion that varies within the set. For example, cell A1 would contain...
[I want to better understand what you did during this visit] During this visit, did the you... (select appropriate answer) [Receive a tour]
A2...
[I want to better understand what you did during this visit] During this visit, did the you... (select appropriate answer) [Meet with the manager]
How would you extract it to just say...
A1 A2
Receive a tour Meet with the manager
The text can vary a lot, sometimes it'll have a second set of square brackets, sometimes not. But one consistency within Google Form data is that the last pair of square brackets is that part that contains the answer that varies. I'd like to get just this text.
...is that the last pair of square brackets is that part that contains the answer that varies. I'd like to get just this text
try this:
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A1:A, "([^\[]*)\]$")))
or more blunt:
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A1:A, "\s\[(.*)\]$")))
Let's say I have a list of patterns such like ['AB', ')', '%%', '<.*>'].
I need to search for one of them forward or backward, starting from the cursor position.
Once the first one is found, how do I retrieve its index in the list? I.e, how do I know which one it is?
[EDIT]: the thing is that I actually have two lists of the same size. Once the first match is found in one direction, I'll need to search the corresponding one in the other direction.
PLUS, each pattern is associated with a certain precedence (its index in the list), which I need to retrieve once it is found.
(The overall idea is to build something that would be able to answer this question, with custom delimiters and operators.)
Got it: the searchpos function with the 'p' flag allows you to retrieve the position and the id of the match in for a compound pattern, see :help searchpos.
Example:
let hits = []
:5s/regex-search/\=join(add(hits, submatch(0)))/g
This add all the matches in line 5 to a list.
However it does also a substitute in the text.
I tried to add the 'n' flag after the 'g'
but that doesn't add the matches to the list.
Is there any way to resolve my problem?
Almost there. First I don't think you need the join. Second, add returns the list with the match added. So you can just select the last element of the list to be the replaced element. (This makes it seem like nothing got replaced)
s/regex-search/\=add(hits,submatch(0))[-1]/g
With a recent enough Vim version, you can prevent that the actual substitution does take place (and messes up your undo-branches), while the expression on the right side of an :s command is still being evaluated.
You need at least Vim patch Vim patch 7.3.627 and then you can simply use
:s/foobar/\=add(hits, submatch(0))/gn
Good day,
I have found a strange quirk in Vim that I can't explain the cause of, so I will describe it to the best of my abilities.
If there is a word that appears multiple times in a file I am editing, I can highlight all instances of it by moving the cursor over the word, and hitting the pound key (ie: SHIFT+3 ==> #). I can then navigate to the next occurrence of this word by hitting 'N' (ie: SHIFT+n), and the previous instance by hitting 'n'.
However, if I perform a search for a word (eg: "int") by using the search command (ie: /int), using 'N' searches backwards, and 'n' searches forwards, resulting in opposite mappings compared to when I use the # key. Is there something I'm doing wrong? I'm using a minimalist VIMRC at the moment.
Thank you.
No, it's correct. / searches forward, ? backwards (similarly * searches for cword forwards and # backwards). And n redos the search in the same direction and N the opposite direction. It's relative to the initial search method.
There's a completion type that isn't listed in the vim help files (notably: insert.txt), but which I instinctively feel the need for rather often. Let's say I have the words "Awesome" and "SuperCrazyAwesome" in my file. I find an instance of Awesome that should really be SuperCrazyAwesome, so I hop to the beginning of the word, enter insert mode, and then must type "SuperCrazy".
I feel I should be able to type "S", creating "SCrazy", and then simply hit a completion hotkey or two to have it find what's to the left of the cursor ("S"), what's to the right ("Crazy"), regex this against all words in the file ("/S\w*Crazy/"), and provide me with a completion popup menu of choices, or just do the replace if there's only one match.
I'd like to use the actual completion system for this. There exists a "user defined" completion which uses a function, and has a good example in the helps for replacing from a given list. However, I can't seem to track down many particulars that I'd need to make this happen, including:
How do I get a list of all words in the file from a vim function?
Can I list words from all buffers (with filenames), as vim's complete does?
How do I, in insert mode, get the text in the word before/after the cursor?
Can completion replace the entire word, and not just up to the cursor?
I've been at this for a couple of hours now. I keep hitting dead ends, like this one, which introduced me to \%# for matching with the cursor position, which doesn't seem to work for me. For instance, a search for \w*\%# returns only the first character of the word I'm on, regardless of where I'm in it. The \%# doesn't seem to anchor.
Although its not exactly following your desired method in the past I've written https://github.com/mjbrownie/swapit which might perform your task if you are looking for related keywords. It would fall down in this scenario if you have hundreds of matches.
It's mainly useful for 2-10 possible sequenced matches.
You would define a list
:SwapList awesomes Awesome MoreAwesome SuperCrazyAwesome FullyCompletelyAwesome UnbelievablyAwesome
and move through the matches with the incrementor decrementor keys (c+a) (c+x)
There are also a few other cycling type plugins like swap words that I know of on vim.org and github.
The advantage here is you don't have to group words together with regex.
I wrote something like that years ago when working with 3rd party libraries with rather long CamelCasePrefixes in every function different for each component. But it was in Before Git Hub era and I considered it a lost jewel, but search engine says I am not a complete ass and posted it to Vim wiki.
Here it is: http://vim.wikia.com/wiki/Custom_keyword_completion
Just do not ask me what 'MKw' means. No idea.
This will need some adaptation to your needs, as it is looking up only the word up to the cursor, but the idea is there. It works for current buffer only. Iterating through all buffers would be sluggish as it is not creating any index. For those purposes I would go with external grep.