Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do vi search and replace within a range in sublime text

I enabled vintage mode on sublime text.. but there are some important vim commands that are lacking.. so let's say I want to do a search and replace like so

:10,25s/searchedText/toReplaceText/gc 

so I wanna search searchedText and replace it with toReplaceText from lines 10 to 25 and be prompted every time (ie yes/no)..

how do I do this with Sublime Text? everytime I hit : it gives me this funny menu.. any way around that?

like image 976
abbood Avatar asked Apr 27 '13 02:04

abbood


2 Answers

If you so much would like to see vim in action, try the other way around; ie enable sublime stuff in vim.

Here are 2 links that might come in handy: subvim and vim multiple cursors (Which is one amazing feature in sublime that lacks in native vim).

Hope that gets you creative ;)

like image 185
tUrG0n Avatar answered Sep 28 '22 13:09

tUrG0n


Unfortunately vintage mode does not understand ranges. The best way I know how to do this is with incremental search:

  1. highlight the first occurrence of searchedText on line 10
  2. hit cmnd/ctrl D to have Sublime find the next occurence
  3. If you you want the next occurrence ignored, hit cmnd/ctrl K
  4. Once you have highlighted all the occurrences, you can replace them all at once, as Sublime has left cursors behind on every occurrence you opted in on.
like image 45
Matt Greer Avatar answered Sep 28 '22 11:09

Matt Greer