It surprises me how users of other major editors don't use multiple cursors in their day to day editing tasks. It'd be awesome if subvim included the best solution vim community has to offer in this regard.
It surprises me how users of other major editors don't use multiple cursors in their day to day editing tasks. It'd be awesome if subvim included the best solution vim community has to offer in this regard.
Do watch the video linked to on this page!
an example:
class="item"
class="item"
class="item"
class="item"
st2 would be able to select the second and fourth line item and be able to change those to "item odd" without touching the first and the third ones. similarly they could do the same and add even to the other two. class="item"
class="item odd"
class="item"
class="item odd"
this blog post shows it in action:http://www.sublimetext.com/blog/articles/sublime-text-2-0-re...
qa$i odd^[jjq
and then '4@a' to run it on all the lines. In a simple case like this is it a bit more complicated than something like multiword editing but I've used this technique in cases that are far more complex then what from my understanding, multiline editing can handle.
For example I turned a spreadsheet of data into a complicated dhcpd.conf file using a couple macros.
/item (search for 'item')
cwitem odd^C (replace with the new text)
nn.nn.nn. (next occurrence, next occurrence, repeat last command) qa // start recording into 'a' register
j // move down
$ // move last char on line
i // insert mode
odd //
esc // back to command mode
j // move down
4@a // replay macro 4 times (if there are 8 more lines)Examples:
- Cmd-Shift-L creates a cursor at the end of every line of the selected area.
- Find all, integrated with Regex, creates multicursors on every match.
- Once you get multicursors, you can still add some manually by holding down Cmd and double clicking at a cursor position.
After you get multicursors, you can then move them around using standard editor commands - that's the real power of this construct, since I'm able to match something much simpler than I actually want to edit (for example end/beginning of line), move to the meat, edit.
:'<,'>s/this/to that/g
I think vim does that automatically when you have a selection active and hit :
So you might consider using :'<,'>s/\%Vthis/to that/g
this ipsum dolor sit amet
this ipsum dolor sit amet
this ipsum dolor sit amet
this ipsum dolor sit amet
this ipsum dolor sit amet
select the middle 3 lines and do what I said will give you:
this ipsum dolor sit amet
to that ipsum dolor sit amet
to that ipsum dolor sit amet
to that ipsum dolor sit amet
this ipsum dolor sit amet
Just give Ctrl-D a try for a couple of days.. It's a total different user experience compared to the traditional find/replace method.
s/syntactic/visual/