My Text Editor Journey: Vim, Spacemacs, Atom and Sublime Text
thume.ca
thume.ca
I feel that Textmate really showed everyone how good a GUI editor could be - we are going back approximately 12 years, and BBEdit, Alpha, Smultron, Hydra/SubEthaEdit were the main contenders at the time.
I concur about Spacemacs, it promises much but things quickly go awry for me whenever I've tried it. Confusion in Vim is easily engineered out in a config or two, and one of the main benefits of learning Vim or its bindings is that it's very likely to still be with me just before I breathe my last.
Text Editors are investments in a fast moving technology industry and Vim/Emacs are a global reserve currency.
Now crucial plugins like Vintageous (vim emulation) are dead and not being maintained anymore.
Then there are things that are still not possible, despite it being an issue for a long time. Stuff like relative line numbers and gutter plugins overriding each other constantly.
Currently I am still using VIM because it does exactly what I want it to do. I know what a keystroke does and why and am one line change away to optimize bad behaviour. But despite that, I have to say that vscode is currently probably the champ out there. You almost don't feel the electron overhead at all. It's blazing fast, intuitive and snappy with an active plugin ecosystem. I'm hoping to get a little bit of free time soon to port some of my vimrc to vscode.
I had also forgotten about VSCode. I like having a GUI editor handy in my dock for quickly opening something drag-n-drop style. And most of the editors I can see in there right now are a little laggy (I'm looking at you Atom, and you, Brackets) so VSCode is now downloading for a quick test.
For now, this will sadly likely keep to prove difficult since the driver situation on linux isn't really good yet.
I use VS Code quite a bit in my current role, and while I agree with most of what you just said, I do have to note that VS Code's startup time is noticeably longer than vim's. There's this weird interval where the window is up, but the editor tab hasn't loaded yet where the program seems unresponsive to input. Once everything is running, VS Code is fairly responsive, but that startup lag isn't something I see in vim.
Restating for emphasis. Text editors are tools. They're means, not ends. As long as you're getting your work done, I don't care whether you use vim, emacs, Sublime, Atom, VS Code, nano, or even notepad.exe.
At my last job, I used vim, one co-worker used emacs, while a third co-worker used Sublime. While we had our fair share of good-natured ribbing, I don't think any of us looked down on the others for using a different editor.
As long as you write all your code on one line
vs
\n
An OS schism derived from a mechanical typewriter (teletype): carriage return.
So FOSS proponents are idiots according to you? Noted.
Life is short, and someone that uses another tool might just have a good reason for it (that can be learned from).
FTFY :)
For this particular article, I think what strikes me as odd is:
> use[ing] the keyboard is slower for some selection tasks like selecting a range of text far from the cursor than the mouse is
This is...precisely the opposite of my experience. I find navigation and selection to be the most powerful aspects of vim. I never felt like I "got" vim until I understood this, in fact. I constantly questioned if the investment of time was worth it. That being said, if you don't grok this I could see how it would be defeating. You eventually reach a point where you forget the mouse is even an option though.
My only other comment is in regard to his mention of issues with tabs. I'm curious what we were doing so differently, because that's never once been a problem for me, even in early days (however I could see how it would be super annoying).
I'm of the mind that it doesn't matter what you use as long as you're being productive, but it's also neat to see what path other people walk down.
Could you tell me; don't you miss a mouse? Or a scrollwheel? Or alt-tabbing? Do you use a project panel wher you can see your files? Do you browse that with your keyboard?
I ask because I always struggle in vim.
Anyway:
1. Mouse - you can use your mouse with Vim.
set mouse=a
vmap <C-c> "+y
vmap <C-x> "+x
vmap <C-v> "+gP
There you go. Mouse actions + Ctrl-V Ctrl-C/X/V for easy copy-paste.
2. Scrollwheel - you can enable the scroll wheel, I can't test right now but I'm pretty sure you can use it. I move around more by Page Up/Page Down (another Vim heresy!) or by searching (a ton more common).
3. You can Alt-Tab using Vim. Just use Gvim. Or did you mean switching tabs with Ctrl-Tab? There you go:
map <C-Tab> <Esc>:tabnext<CR>
map <C-S-Tab> <Esc>:tabprevious<CR>
4. There's quite a few plugins for that. NerdTree, for example.
Anyway, don't feel forced to use Vim. I use it because it's cross platform, free and I'm used to it. But don't drink the KoolAid. It's not some magical weapon. Especially if your mental model doesn't match its model. For example in my case it matches only partially (see the whole arrow keys, copy-paste, mouse usage, etc.). But I still use it because I like the modal editing and to be honest, I think that for me command mode/ex mode is what keeps me using it. :s, :g, :tabnew & co. are too darn useful.
To browse my files I use NERDtree, which acts like most project panels in IDEs, and yes I browse it using the keyboard.
Not sure what you mean by alt tabbing though.
If you're using a file tree, you are probably doing it wrong. Instead, get used to tools like Command-T and the :vim command. Also set incsesrch and hlsearch. Once you learn how these things work, start making a conscious effort to play a bit of vim golf to get to where you're looking to be in as few keystrokes as possible. It's a bit painful starting out, but once you get over the hump you really will feel like the mouse is obsolete.
I don't miss the mouse or scrollwheel at all when using vim. HJKL, as nice as it is, is probably the least efficient way to navigate code with vim. You're much better off navigating by word or by using / to just search for where you want to go. Having regex search just a single keypress away is amazingly powerful once you start really using it.
As far as alt-tabbing goes, I'm not sure what you mean. I alt-tab in and out of vim all the time. If you're having trouble with that, then perhaps something is wrong with your vim configuration.
I do not use a project panel to browse my files. That's IDE thinking. Vim is a text editor, not an IDE. Unix itself is the IDE. If you want to browse/navigate files, you should be using the shell, not vim. If you want you file browser and your text editor in the same window, you should be using screen, or tmux, rather than hacking additional panes onto vim.
I suspect your problem is that you're not using vim enough. Learning vim is much more like learning a musical instrument than it is like learning a programming language. You can't expect to master the piano if you only play one hour a month. Similarly you can't expect to master vim if you only use it to edit the odd config file on your server.
A tags file and ^] and ^t to navigate is faster than file browsing and scrolling around. * and # to quickly jump between instances of the same token. ^6 to quick swap between buffers, and ^o and ^i to quickly jump back and forth between locations I've visited.
Fast cursor movement using b, w, {, }, /search, [[, ]], is also much faster than mousing around or slowly navigating using arrow keys.
Scrolling is done by ^e and ^y, and zz to center on the cursor. Faster than a scroll wheel.
And don't forget the almighty '.'. To quickly replace a variable name, stand on the variable, hit * to search for it and remember the search. Then 'cw' to change a word, type the new name, hit escape. Then 'n.' to find the next instance and repeat the edit.
That last in particular is going to be a big help. No more `:e #` for me!
nmap ; :
set grepprg=git\ grep\ -n
nmap <F7> :cp<CR>
nmap <F8> :cn<CR> noremap ; :
noremap : ;
But that might take muscle memory too much time to adapt. (And would it break plugins?)I've already got F7 and F8 mapped, but I'll hunt out a spare key(sequence) for the mappings you suggest.
What, I have to move my hand off the keyboard, over the numpad, land on the mouse, register where the pointer is, move the pointer to whereever, do the action... and reposition my hand back on the keyboard?
Seriously though, you do start to edit faster in vim once you 'get it', and I'm not all that great with it myself. I have seen a vim god in action and I've never seen anything so fast at editing. This all being said, vim is much more suitable for system administration than developing, IMO.
The only time I miss a mouse is when I want to fire up a game that actually runs on my Mac (Dwarf Fortress, Rimworld, etc.). I'd say the main reason I don't miss a mouse in vim is because I don't use a mouse anywhere else on my Mac. On a fresh format I create 4 desktops, and I bind CMD+1-4 to switch between these. Whenever I want to launch chrome/term/mail/whatever I use CMD+space and launch it directly from Spotlight. I use Magnet (http://magnet.crowdcafe.com - no affiliation, just a fan) to maximize/minimize/layout windows without having to use the _remarkably awful_ Mac window management UI.
While within vim I don't miss a scroll-wheel because bouncing around with / and ? is just so, so, so much faster. I really cannot stress enough how slow it now feels to scroll up and down a file searching for a specific string when I'm forced to do so. It's maddening for me now.
Your question re: a project panel, etc, is probably the best one. I think I may be an outlier here. I don't use NERDtree, but a lot (most, in fact) of my friends who use vim do. There are really two use cases for opening a file - direct from the term or in concert with an already open file. I typically know the structure of a project so I can just cd around or vim right/to/the/file.js If I'm already editing something I'll usually just :vsp to/the/other/file.erb or if I'm really lost as to where I am or where I'm trying to go I'll just CTRL+Z back to the term, cd & ag around until I find myself, fg back to vim, then :vsp to/where/I/now/know/Im/going.scss
I suspect if I actually spent the time to learn NERDtree I may be able to get around unknown projects better, but I've always felt pretty good about my workflow so I've just never committed to it.
However, you can have both. Neovim is a drop-in replacement for vim that lets you use the mouse to select text, scroll, change windows or panes, resize splits and so on. Resizing splits is one of those things that I prefer to do with a cursor.
I think vim can do some of the same things (all?), but it requires some configuration.
set mouse=aI don't think it requires anything beyond `set mouse=a` in your vimrc, and not even that if you're using gVim.
Reading further down I also saw that most of his complaints were about Emacs not about Vim. So all we can say is: he didn't bother enough with Vim yet.
How about a test? Suppose my cursor is on line 198 of https://github.com/trishume/syntect/blob/ef3b99b06b72e89b7a0.... I want to copy "match_pat.has_captures && cur_level.captures.is_some()" on line 172. If you give me an efficient sequence of vim bindings for that movement I can tell you if I know what everything does without looking it up.
I think a more apt criticism would be that I think too slowly to use Vim. I can figure out that "26j4wy10e" does what I want, and at my normal english characters/second typing speed that is faster than doing the selection with my mouse. However, when I actually try and do that without figuring it out ahead of time I take longer to read, count and figure out the right numbers and actions, then type the individual characters (which due to muscle memory for english I'm slower at than typing english). I end up being slower than the mouse, and with a higher mental load.
You could say I just need to "git gud" and practice, but if practicing for hours a day for 5 years doesn't get me to the point that I'm better than the mouse, I think it's time to say that maybe it isn't a lack of practice, but perhaps an innate skill difference.
That all presumes that there exists a substantial number of people who are faster in practice at long distance text selection with vim shortcuts than I am with the mouse. I have yet to see someone where I can confidently say that is the case, and I've watched a reasonable number of vim users. I guess everyone I've seen using vim (including many 5+ year users) is a "vim n00b" in your model, that sounds a bit "no true scotsman"-like.
But if you use your limited knowledge to judge vim, I have to point out that there is a vast ocean of editing power and you've only put your toes in until now.
The condescending one is really you in that instance, since from what you've written vim can't be in the same class as Spacemacs or Sublime. And this leads to many people ignoring vim, who might have gained a lot of insight into text editing by learning it. So yes, it needs pointing out that you know so little about it that you haven't been able to really assess its power yet. But if you learn it or not is none of my concern. If you want to really learn it, I can give you some good material, though.
E.g., if you want to really see something that vim is great at, maybe better at than any other editor, check this out: https://vimeo.com/15443936
PS: I hope you notice the phrasing here. There is something vim is probably the best at, doesn't mean that there aren't other things other editors aren't better at.
I don't think, or at least I didn't intend, anything I wrote to imply that "vim can't be in the same class as Spacemacs or Sublime". It's definitely a very powerful text editor. My only complaints about it are plugin conflicts, discoverability and mouse hostility. Which are all things that can be worked around.
What I'm trying to do is argue against the thesis that you need to learn Vim/Emacs to get that level of power. Sublime can give you that power just as well and with some benefits.
I watched the entire video you linked, everything in there can be done in plain Sublime just as easily (without Vintageous even, and definitely with), with find+replace, multiple selections and macro saving for the last step of turning it into a script. I do acknowledge however that I learned one new vim thing, which is the g command for finding and then doing something, analogous in purpose to Sublime's "find and select all".
The only thing I think I disagree with you on is this: "But if you use your limited knowledge to judge vim, I have to point out that there is a vast ocean of editing power and you've only put your toes in until now." This seems to imply that there are facts about Vim that I don't know that if I knew them would make me faster at using Vim than I currently am at Sublime Text. I agree that if I had perfect Vim knowledge I would be just as fast as I am at Sublime Text, but not substantially faster.
In terms of a prediction, I believe that there is at most two editing tasks I've done in the past year that given more Vim knowledge I would have done over 1.5x faster than I did it in Sublime. It seems you disagree with me on this point, you can convince me by showing me a new Vim fact I didn't know (I do know quite a bit) and I can tell you if it would have helped.
Notably this does not specify that I magically increase my brain power to be able to instantly apply the Vim knowledge in the best possible way. I'm fully aware that if I could instantly determine the shortest Vim key sequence to accomplish a task and type it as fast as I do english, I would be way way faster in Vim. I contend that I personally could never do anything close to this regardless of how much I learned or practiced. In the same way that despite knowing a programming language and practicing programming a whole lot, I can't come up with the perfect program for a task instantly and type it as fast as I can type English.
Basically I think we agree that Vim is more powerful than Sublime without Vim emulation. We disagree on how much of a Vim n00b I am and how much better I could be by learning more. I'm uncertain of your stance on how much of Vim's power is not accessible through Sublime with Vim emulation. I contend that there is little additional editing power to be gained by stepping from Sublime with Vintageous to real Vim.
This is the real problem. You don't owe anyone any explanation for the text editor you use. Personally, I'm an emacs man. I know lots of people who prefer vim. Some prefer Sublime Text. Some even prefer TextPad Pro. That's fine. That's their business and at the end of the day what I care about is their code, not the editor they're using to hack on it.
If people get frustrated with their editor and ask what I'm using, then I'll tell them about emacs. But I'll also tell them emacs isn't for everyone. To wit, in the case the author mentioned of finding other files in his project I'll either use dired or open an emacs shell window and use find. This is a great workflow for me. Others would find it abhorrent. To each their own - and that is the point!
I'm a happy user of Sublime Text now, have been for years. It's such a relief. I know none of its features and it feels great. I enjoy the speed, mouse support, clear text, its remembering of all unsaved files and other user friendly features.
The battery lifetime argument made me stick to vim, too.
Oddly enough, I recently tend to use VSCode when being attached to AC. It really seems that Microsoft gets this more and more right. They even added the Minimap after listening to their users. Let me repeat: Microsoft. Listening. To. Users! Still can't believe it.
However, my main argument for VSCode are side by side previews: Eases writing, while pleasing the eye. Vim simply isn't made for this.
Even I can't believe that MS is running a famous FOSS project and they actually listen to users, times are great :-)
Still, vim = awesome.
No evil-mode, no super-bloat spacemacs, just barebone emacs with maybe one or two plugins??
Because some of us would still like to be programming in 20 years' time rather than being crippled by carpal tunnel ;)
I included a smiley, but I'm only half jesting. I tried to use native emacs for a while, but even after remapping caps-lock to ctrl, I was getting weird twinges in my wrist from all the odd angles I was having to go to in order to hit ctrl and meta. I switched back to vim, and the twinges stopped.
I didn't know about evil mode or spacemacs then, otherwise I might have tried to stick with emacs.
It took me a long time to even consider that new-fangled 'vim' thing.
What's your view?
Regarding you other point, I think it's the other way around because vim users can't learn a new set of keyboard shortcuts if their life depended on it and that's basically why we have evil mode.
Yes it would have been faster and more stable, however then I would just complain about the lack of a bunch of features from Sublime that I like, and the terrible keybindings.
I actually have minor RSI issues, I'm also not keen to turn them into major RSI issues by using Emacs bindings.
As I often say, IMO vim is the best text editor in terms of actually editing text, bar none. Unfortunately, all the million surrounding tasks that you need to do, e.g. opening and switching between files, searching, etc, are terrible in stock vim. I've taken the path of installing tons of plugins to make vim work better, but it's still not as smooth as something like Sublime. I check Sublime once a year or so to see if the vim mode there is "good enough" yet, and it invariably isn't :(
Btw, my transition was IDEs (and Slickedit at some point) -> Emacs -> back to IDEs -> Sublime Text 1 (for which I wrote a few plugins) -> vim.
I was amazed I ended up falling in love with an editor from Microsoft of all people, but they seem to have learned all the right lessons from Atom.
But after a while you start noticing that the the fact that emacs is 100% hackable is also its biggest problem: everything is possible, and tons of plugins exists. Because of this, a lot of interactions between plugins start to go wrong. The nice plugin that shows you a bar at 80 characters is working well… except in HTML files where this is breaking the display/indentation/completion. Or this other plugin that fails in a specific language, or that other one that doesn't work for diff editing. I got tired of always fighting and wasting time with plugins and configurations.
So I started to look at other editors. Atom? Too slow. Vim? Not an IDE. Sublime? Not open-source. And then I found VSCode, refreshing. I start to love it (and feel bad about this, because… Microsoft, you know…). My problem now is that Spacemacs has put the barrier of keybinding efficiency so high that none of the other editors can compete. Whenever I try another editor, like VSCode, I miss the efficiency of Spacemacs, and especially Magit (one of the most awesome pieces of software I have used). In Spacemacs I do absolutely everything without mouse, with VSCode I have to use the mouse, so it's less efficient (though this has been widely debated recently [1]).
I'm stuck.
You could try Acme. It feels great (zen-like, actually) not having to remember a dozen keybindings, not maintaining configurations and simply clicking around and using whatever is on your $PATH.
Eclipse really helped me with its Git integration and when PHP got more sophisticated I really appreciated the help the IDE gave me over Notepad++.
I switched to PHPStorm because it was way cheaper than VS but had better support than Eclipse and more up to date features that helped with PHP.
But it got heavier and heavier and the company I worked for would not buy new dev machines, so one day I switched to Sublime Text, which felt like a speedup by 100x. Also I switched from PHP to JavaScript in that time. PHP had better typing so the IDE could help much more than with JavaScript, so I didn't see much gain in using PHPStorm or WebStorm.
Then Atom came out and got updates and new modules faster than Sublime Text and since I was now mainly a JavaScript dev, it just felt right lol.
But Atom was also much slower than Sublime and the modules were often low quality. So I tried VSCode, because I read a few good things about it and it really was better. Not as fast as Sublime Text, but faster than Atom and still with bleeding edge modules and updates.
It's becoming more and more of a modular IDE, but I think their module system is rather good so I think they can keep up performance wise for a time now.
I also tried stuff like Brackets, Vim and Emacs, but they either felt too simple or they had a too steep learning curve for my taste.
I mostly stick with Vim now since I can easily work through any issues I do encounter with the plugins, and there's no extra layers to worry about.
Very true. I've used Emacs almost exclusively for 20 years, and what I've found is what you've just said: the key is to use Emacs on its own terms. Otherwise you're fighting too many deeply ingrained behaviors, etc. (The corollary to this is that the reverse is true also - Emacs keybindings for other editors tend to be unsatisfying. They bring the surface, but not the essence of Emacs to some other tool.)
I find it helps me write code that other people can understand and use. IDK why the text editor has such a big impact. Maybe the frustrations of certain actions in certain editors discourages those actions and subtly biases the code I write. I've not dug into it too deeply.
The one thing I hate is managing plugins and configs. This stems from my other habit of trying a new OS every year, too. The only way to keep a consistent config across all of these states is to just accept the default config as the one, true config. If a feature is good enough to be a plugin, it's good enough to be in the software.
I've been very keen to go on another text editor adventure, this time with focus on creating a good experience on mobile devices.
Clearly, you shouldn't have used tab to do all the things, it is bound to create confusion, if you use tab for everything.
Mouse support is first class in Gvim/Macvim.
My opinion as well although I am not as experienced as the author.
For instance I hardly miss auto complete and file trees.
Correct. One of the reasons I don't go the Emacs/Spacemacs way
Yes, Spacemacs is a pile of hacks on top of emacs which is a pile of hacks on top of elisp which is a pile of hacks on top of a terminal emulator which is...
Does it matter if they're hacks? Or does it matter that they're good hacks?
Not to mention the political issues w/ Emacs