sponsor Vim development Vim logo Vim Book Ad

vim-select-replace : selectively replace or delete the cur. word or selected text in multiple places

 script karma  Rating 0/0, Downloaded by 649  Comments, bugs, improvements  Vim wiki

created by
Enno Nagel
 
script type
utility
 
description
By this Vim plug-in, you can:

1. Hit c or d followed by *, #, g* or g# to replace respectively delete the current word. Now either:
  A. Press n/N to skip the next occurrence of this word, or
  B. Press . to repeat the previous move and change or deletion.

1. Hit s or x in visual mode to replace respectively delete the selection under the cursor. Now either:
  A. Press n/N to skip the next occurrence of this selection, or
  B. Press . to repeat the previous move and change or deletion.

# Configuration

To change the default mappings, add your modifications of

omap  *  <plug>(vim-select-replace-star)
omap  g* <plug>(vim-select-replace-g-star)
omap  #  <plug>(vim-select-replace-hash)
omap  g# <plug>(vim-select-replace-g-hash)

xmap  s  <plug>(vim-select-replace-s)
xmap  x  <plug>(vim-select-replace-x)

to your vimrc.

# Hints

To selectively replace by a confirmation dialog the current visual selection
by a string to be supplied on the command-line, add

  xnoremap S "*y<Esc>:<c-u>%substitute/\V<c-r>=substitute(escape(@*, '\/\|'), "\n", '\\n', 'g')<cr>//cg<Left><Left><Left>

to your vimrc!

# Credits

These ideas to make good use of ":help v_gn" have in essence been divulged by Romain Lafourcade.

# Issues

vim-select-replace is developed at

https://github.com/konfekt/vim-select-replace

where issues can be filed.


 
install details
Unzip vim-select-replace.zip into  ~/.vim on Linux or %USERPROFILE%\vimfiles on Windows.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-select-replace.zip 1.2 2021-12-19 7.0 Enno Nagel fix function name
vim-select-replace.zip 1.1 2019-07-10 7.0 Enno Nagel Improve obtention of visual selection
vim-select-replace.zip 1.0 2019-04-27 6.0 Enno Nagel Initial upload
ip used for rating: 207.241.235.164

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
OSDN