3
votes
1answer
80 views

What does the search flag 'z' do in VIM?

I was looking for a way to show a bit of context around my searches when doing g/mysearchtext/p When I stumbled across this page Search-a-pattern-and-provide-a-context-few-lines-above-and-below ...
8
votes
2answers
313 views

Is there a command reverse search in vim?

In linux cli I can do ctrl-r and do a reverse search and choose something I have done easily. Is there something similar in vim? I mean I may run a command using : (could be anything like a long ...
4
votes
4answers
759 views

vim search numbers containing specific number of digits

I need to find specific length numbers in a big document. I tried to use regex for this. For example, If I need to search for numbers with exactly 2 digits, I use /d/d (i.e. /d twice followed by a ...
0
votes
2answers
224 views

Vim: searching upward/downward in file from specific point/position

I want to search a word from my current cursor position in vim to upward in file. How to achieve this? Also how to do same for downward in file.
1
vote
1answer
44 views

Replaced matched text in Vim with pattern

Here's a minimal example of what I'm trying to do. Start with: "this") "that") [hundreds of lines like this] End with: "this",&this) "that",&that) [hundreds of lines like this] I have gotten this ...
2
votes
3answers
437 views

How to reverse-match a string in the Vim programming language?

I want to find the last index of any character in the [abc] set in the abcabc string but the search should start from the end of the string: " Returns the 0th index but I want the 5th. let ...
6
votes
1answer
260 views

vim: how do I set :match and :2match search results to different colors?

For example, I want something along the lines of: :match search /<div/ guib=Green :match search /<\/div>/ guibf=Blue only that doesn't work.
4
votes
1answer
691 views

How can I search for and highlight multiple strings in VIM?

In VIM, how can I search for multiple strings and have a different color highlight for each match?
5
votes
1answer
435 views

Conditional search and replace on a line in vim?

Let' say I want to comment and uncomment a line. I know I can :s!^!//! and then :s!^//!! Now what if I want this as an one-liner? Basically, if a line starts with // then remove it, else add ...
2
votes
1answer
101 views

How to limit a search to the current line

VIM newbie here. I'm trying to write a mapping that will let me move around 'common' insertion points in a line when in insert mode. For ex. I have the delimitMate plugin - so typing a opening ...
6
votes
3answers
3k views

Vim :s replace first N < g occurrences on a line

In vim, I sometimes have occasion to replace the first few occurrences of a match on a line, but not every one like g would. e.g.: a a a a a to b b b a a I know I could use ...
7
votes
1answer
374 views

Case-preserving search and replace in vim?

In vim, I know I can search with or without case sensitivity. But if I want to search for a string in either upper or lower case, and replace it with a replacement of the same case, is that possible ...
1
vote
3answers
291 views

vim/emacs plugin to view recursive grep search search results?

Suppose I have a file formatted like this: file1:123 file2:4444 some/other/file:2233 This represents the search results from a grep (i.e. file:line-number). I'd like to have a vim plugin which ...
6
votes
4answers
932 views

vim search around line breaks

When I am editing a LaTeX document in vim, often times I want to search for a phrase. Because I have LaTeX setup to wrap lines, sometimes half of the phrase will be on one line while the other half ...