A. Neumann
A. Neumann

Reputation: 538

Vim: Interactive 'Find and replace' like in atom/sublime?

I'm currentlich switching (from atom) to vim and one of the features I miss most right now is atom's find and replace function. It mainly allows me to highlight a word, incrementally select matches of the string (default: ctrl-d, skipping findings: ctrl-k) and afterwards do whatever I want which is often replacing parts within all selections, creating a new line below every selection inserting stuff, etc.

Question: Is there a similar feature in vim? I'm not looking for regex-based global find and replace, I know how to do that in vim. I'm specifically looking for a some kind of interactive version.

thanks in advance, Andi

EDIT

This plugin does exactly what I'm looking for (better search term: multiple cursors): https://github.com/terryma/vim-multiple-cursors

Upvotes: 1

Views: 536

Answers (1)

Kent
Kent

Reputation: 195039

I have zero experience with atom. However what you described could be done in vim.

You need in your config this two lines:

set incsearch "incremental searching
set hlsearch  "highlight match

Then you can just in your buffer do

  • /whatever, you will see the incremental highlighting.
  • When you finished your pattern/word, press Enter all matched texts will be highlighted.
  • Now do a :%s//FOO/g all those matched text will be replaced by FOO.

If this is not exactly what you want, please make an example to show how it works, not everybody here use atom.

Upvotes: 1

Related Questions