Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't want to start a flame war; I don't consider myself a die hard vim user: What are reasons why I should switch to Sublime Text 2?


I switched to vim a year ago, and I fucking love it. The one thing I miss from ST2 is column editing/multiple cursors. Column editing fulfills the same kind of need as basic usage of vim macros, I think (i.e., applying some kind of sequence of edits to multiple rows), but it's visual and you get instant feedback (across all rows), which makes it easier and something you can sort of feel out iteratively.

For example, supposed I have a row like (making up these names as I go, and suppose the list is longer):

  Controller_Section
  House_Model
  Person_To_Category_Selector
and I want to insert after the first underscore the word class, so I'd get Controller_Class_Section and so on (this is a contrived example, but one has to do these kinds of things sometimes.)

In vim, I think I'd record a macro, but I'd probably forget some parts (like moving to the next line at the end) and have to undo and whatnot (could use a regex too, but that's a bit harder--I'm practicing recently to be able to do it more effortlessly.)

In ST2, what you do first is create a cursor at the beginning of each row (option + down arrow on OS X.) Then you move ahead one word (Opt + Right arrow on OS X.) Now the cursor is right before the underscore, even though the underscore is in a different position on each row. You can see that it's in the right place on each row, so it's hard to make a mistake, and if you need to do something more complicated, that remains true. Then, you just type _Class, and it types live on each row, once again making it so you get instant feedback, and it's hard to make a mistake.

That to me is the biggest actual advantage of ST2 over VIM, but there are other reason to not switch, like vim's steeper learning curve (when most of us are already busy, and learning other stuff at the same time), and the fact that some people prefer the mouse, which behaves strangely in vim.


Multiple cursors sound cool! In vim, you can do something more limited by using visual block mode (C-v) to insert on multiple lines, but you're restricted to insertion on the same column.

The perhaps the closest thing I can think of for your example would be this (starting in normal mode with the cursor at the beginning of your list):

    f_i_Class<Esc>+;.+;.
("Move forward to the next '_', enter insert mode, insert '_Class', leave insert mode, move down one line to the first non-blank character, repeat the forward motion, repeat the insertion, repeat forward motion, repeat insertion." Vim does have word motions, but it includes underscores as parts of words.)

Edit - formatting and a clarification that it's the closest I can think of (I'm doubtful it's the closest you can get).


You wouldn't do the following?

   :% s/_/_Class_/
Explained: On each line replace the first '_' with '_Class_'


Yeah, that's totally what you'd do, in either editor. But my broader point is that there are situations where the immediate feedback and interactivity of using multiple cursors is valuable.


How is immediate feedback and interactivity going to help if the changes span more than one page? If you are going to extrapolate(looks fine on this page, must be fine elsewhere), you can very well extrapolate from a smaller sample size(run :s/some_crap/some_other_crap/gc, check one or two occurrences, then do 'a' for all).


One can always stop typing and simply scroll down and check.


I've tried to like it and believe that instant feedback is actually useful but no. I couldn't.


Emacs IEdit mode has done this for years


Yeah, I'd record that as a macro and replay it line by line I think.


Rather than replaying it line by line, you can play it over a range. If you do this in your vimrc:

    vnoremap @q :normal @q<CR>
You can record the macro in q register, select the visual range, and then do @q to run it over the range. The advantage of doing it thus is you don't have to run the macro manually on every line, and you can undo all change with one u.

Also, normal takes ranges(and not just visual ranges). If you want to run the macro recorded in q over lines 15,49, you can do:

    :15,49normal @q<CR>
I use the same trick for repeating commands over a range too.

    vnoremap . normal .<CR>
As usual, it doesn't have to be visual range. But I mostly use visual ranges, and so I have defined shortcuts for visual ranges.


Macros are the way I solve this as well. A little practice, and you won't even notice the difference. Just hit `Esc j` before ending the macro recording and moving down a line is no longer a problem :)


I usually use "repeat last change" (. key in normal mode by default) command in vim without a macro for the tasks like that. http://vim.wikia.com/wiki/Repeat_last_change

To do the task you mentioned in vim I would move the cursor to the first letter of the word Section in the first line. Then I'd insert "Class_" and go back to normal mode. After that I'd move the cursor to the first letter in the word Model in the second line. And then I'd press the dot key and do the same with the other lines in supposedly longer list.


> And then I'd press the dot key and do the same with the other lines in supposedly longer list.

I am posting this again(posted above about running a macro on a range), but I guess lot of people don't know about this.You need not manually press . on every line. You can run . operator on a range. Do a visual select and then

    :'<,'>normal .<CR>
The range('<,'>) is inserted automatically when : is pressed from visual mode. So it boils down to visual mode, select, :normal . <CR>

You can have any ranges you want.

    :15,49normal .<CR>
I have a shortcut for visual range defined in my vimrc

    vnoremap . :normal . <CR>


I do that with Sublime Text 2 using the vim plugin (vintage). I would've never switched from vim if not for this plugin. Now I have (most) of the best of both worlds.


I have to say vintage did my head in. I guess to me, vim requires a different mindset to a "modern" editor, and vintage mixed the two.

Now I seem to spend a few months with vim as my primary editor, get tired of it, switch to ST2 for a few months and then switch back.


Use <C-v> for column editing.

Your example is not a candidate for a macro, a simple substitution is enough:

    V2j to visually select the lines
    :s/_/_Class_<cr> a range corresponding to the visual selection '<,'> is inserted automatically before the s
If you are comfortable with ranges, the operation can be done in one go:

    :.,+2s/_/_Class_<cr>
Also there are already a few plugin authors exploring the multiple cursors idea, however gimmicky it is.


I use Sublime Text 2 for its GUI powers: proportional-width fonts (I use Verdana), the code minimap, and the pretty file-browser sidebar with easy-to-click disclosure triangles.

I also like that it’s easier to remember most Sublime Text 2 commands – the Command Palette (⇧⌘P) lets you fuzzy search all commands. So you can search for “syntru” and find the option “Set Syntax: Ruby” instead of having to remember Vim’s “:setf ruby”.

Finally, I use Expand Selection to Word (⌘D) to quickly select multiple instances of a variable whose name I want to change – it’s slightly more convenient than it would be in Vim.

On the other hand, I miss Vim’s editing model. It’s a lot more cumbersome to edit line-wise or move the cursor with Sublime Text’s keyboard shortcuts. And Sublime Text’s “Vintage” Vim emulation mode is a poor substitute. As another commenter said, Vintage is in the uncanny valley. Every now and then you run into a Vim command that just doesn’t work and it breaks your flow. For example, Escape is overloaded as both “go from Insert mode to Normal mode” and “collapse multiple carets into one”, and I never remember which it will do when I have a multiple selection in Insert mode.


I've been in the process of switching from Vim to ST2 for a couple months (custom plugins in both, not in a hurry) and the main reason for doing it is because Python and the extension API are MUCH better than the Vim equivalents. If you don't do custom plugins, it really doesn't matter.

Part of the reason for the delay is the lack of equivalent Vim workflows in Vintage. This has been improving a lot thanks to the people working on Vintage and at this point the only holes in my set are c-i/c-o and surround.vim shortcuts. I had to re-train myself to go from Esc to ctrl-[ since Esc conflicts heavily in ST2 but I've been meaning to do that for years in Vim anyway so I consider that a benefit.


If you're not a die hard vim user but do enjoy vim navigation/insertion styles then you may want to try out Sublime's Vintage mode:

http://www.sublimetext.com/docs/2/vintage.html


I tried this after learning vim, and it seemed to suffer from an uncanny valley problem. Once you get into the flow of things, you'll start treating it like vim, and then when something suddenly behaves slightly different or doesn't work at all, it's very disruptive. I can't think of a specific example right now unfortunately, as that was a while ago, but it happened regularly.


Uh, I'm in the same boat as the person you responded to and I am still confused. What are the advantages of sublime over vim (rather than ways that Sublime can emulate vim)?


You can find the dev branch of the vintage plugin here: https://github.com/sublimehq/Vintage

Also see https://github.com/SublimeText/VintageEx which adds the vim command line.


It does not support Vim's wonderful vit, vat tools. Perhaps none supports like Vim. My fav for HTML/div editing.


No reasons really. I have found Vim better at tweaking. None can match that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: