Emacs org-mode: search visible content only, not collapsed? - search

In Emacs org-mode, I sometimes do sparse tree searches to list only headlines that match a tag.
I would like to be able to search only what is currently visible (matching headlines), not the whole buffer as does Isearch. Is this possible natively or via some package?
Edit:
As per comment, answered in: Make isearch skip folded content in org-mode
Search behavior can be customized using the search-invisible variable, or toggled via M-s i during a search.

Related

How to make vim show search result list dynamically while :tj SomeSymbol is being typing?

all. I know after generating a tag file, when I use :tj SomeSymbol, I can either jump to the expected location when SomeSymbol is unique within the project, or be given a list to choose. But I want more convenient way.
When I'm typing :tj SomeSymbol, I wish there's a popup menu showing all possible locations as if vim was searching the tag file for the expected symbol. In this way I can choose quickly and conveniently.
The final effect I want may be like what qtcreator gives:
So is there any way to do this ?
There is nothing built-in. Vim's completion popup menu currently can only be used for selecting candidate matches to be inserted into the text; it's not a general-purpose selector / filter. For tags, Vim only offers the selection by number as in the :tselect / :tjump commands. However, some plugins have implemented custom filtering (often in combination with fuzzy matching for easy drill-down into the candidate lists). I still use FuzzyFinder, which (though unmaintained for quite some time) offers (among others) a :FufTag command that lets you interactively select from tag matches.

Visual selection and replacement in vim

How can I select different portions of multiple non-contiguous lines and replace them with the same/different text?
Example: Let's say my buffer looks like this-
Roses are reed,
Violets aree blue,
Sugaar is sweet,
And so are you,
I want to change in 1st line the 3rd word ('reed') to 'red, yellow and green', in 2nd line 'aree' to 'are', in 3rd line 'Sugaar' to 'Sugar and molasses' and in 4th line 'you,' to 'you.'.
Say my cursor is at 'R' of 'Roses'. I want to select all four of these wrongs at once and nothing other the wrongs. After I'm done selecting I want to be able to move to 'reed' by pressing some key (say Ctrl+j), then after changing I want to be able to press some key (say Ctrl+j) and move the next visual selection which is 'aree'.
Is there any plugin that does this?
There are multiple cursors plugins that attempt to create parallel editing functionality seen in other editors to Vim (which is difficult). If I understand your use case right, that wouldn't help here, though, because all places would be edited in the same way (so reed, areee, etc. would all be replaced with the same red).
Instead, what you seem to be asking for, is a way to search for all wrongly spelled words, and then edit them one by one, individually. You can do this with standard search, using regular expression branches:
/reed\|areee\|Sugaar\|you,/
You can then simply press next to go to the next match after you're done. Note that the branches have to be unique (so I searched for you, instead of simply ,). Adding word boundaries (\<reed\> instead of reed) is a good idea, too.
plugin recommendations
multiple cursors is a famous plugin for parallel editing
My SearchAlternatives plugin lets you add the current word under the cursor as a search branch with a quick (<Leader>+ by default) key mapping. (However, if you're already on the word, why not correct it immediately?)
My SpellCheck plugin populates the quickfix list with all misspelled words and locations. You can then use quickfix navigation (e.g. :cnext) to quickly go to each. The plugin also offers mappings to fix spelling errors directly from the quickfix list.

Is there a one-liner to tell vim/ctags autocompletion to search from the middle of a word?

In vim (in Insert mode, after running exuberant ctags), I am using ctrl-x followed by ctrl-] to bring up a dropdown of various possible words/tokens. It's a great feature.
The problem is that by default, this list starts with a bunch of numeric options and automatically inserts the first numeric option, and if I backspace to get rid of the numbers and start typing a part of a word fresh -- with the idea of searching from the middle of the word -- the autocompletion behavior exits entirely.
I know I could type the first letter of the word that I want, then go from there. But that assumes that I know the first letter of the word, which is not necessarily a given.
For example, if I'm working on a pair-programming project with a friend during a long weekend, I might not remember at any given moment whether he called his method promoteRecordStatus(), updateRecordStatus() or boostRecordStatus(). In this example, I would like to type RecordStatus and get the relevant result, which does not seem to be possible at a glance with the current behavior.
So with that scenario in mind: Is there a simple, vim-native way to tell the editor to start its autocompletion without any assumptions, then search all available tokens for my typed string in all parts of each token?
I will of course consider plugin suggestions helpful, but I would prefer a short, vim-native answer that doesn't require any plugins if possible. Ideally, the configuration could be set using just a line or two.
The built-in completions all require a match at the starting position. In some cases, you could drop separator characters from the 'iskeyword' option (e.g. in Vimscript, drop # to be able to complete individual components from foo#bar#BazFunction()), but this won't work for camelCaseWords at all.
Custom :help complete-functions can implement any completion search, though. To be based on the tags database, it would have to use taglist() as a source, and filter according to the completion base entered before triggering the completion. If you do not anchor this pattern match at the beginning, you have your desired completion.

Vim: How to search for more than one word in the same search?

Is it possible to search within vim for more than one word?
For example:
Let's say i'm inside vim and I press / in order to start a search for a certain word, is it possible to search for more than one word in the same search?
Yes, you can have several branches in a search pattern:
/foo\|bar
See :help \|.
Use the OR operator
/first\|second
If you do this often, my SearchAlternatives plugin may be useful to you.
The plugin provides mappings and commands to add and subtract alternative
branches to the current search pattern. Currently searching for "foo", but
also want to find matches for "bar"? You could type /foo\|bar<CR> or
/<C-R>/\|bar<CR>, but once you want to limit the search to whole \<words\>
(like the * command), and juggle several alternatives, adding and
dropping them as you search, this plugin is quicker than manually editing the
search command-line (which you can still do).

Cscope Syntax hightlight search within search

I am using CSCOPE for my project and I have few question.
1) Can I color the search result (mostly when I serach using
":cs f s " i.e. within the open file.
2) Is there a way to search within search? Like I search "ret_val" and it gave 1000 result, instead of going each line, can I search some more like folder name etc?
I am not sure how you use the tool, but generally, the answer is yes.
1) You could either redirect results to file, lets say out.cscope then create syntax file for file type *.csope OR, use a function to run the tool, then locally set up the buffer with adequate hi and match options
2) If you saved search results in a cscope file then you can search it normally. Otherwise you can redir output to new tab/split and again search the buffer (which now doesn't need to have externally associated file. I suggest you to use vim-foldsearch plugin to fold out anything (not) in the match. You can even delete folded sections (with or without any number of context lines) so that only stuff you are interested in finally remains in the buffer (i.e. it behaves like filter). Alternatively you can use unite plugin and it filtering source lines which filters lines as you type the keyword. Actually, I would personally go with that option as it provides most interactive way of working.

Resources