Some background
The first week of using Emacs I was averaging about ten words a minute; between consulting Emacs cheat sheets and lying paralyzed on the floor from RSI-induced pain I didn't have much time left for actual typing. However, as time passed, I became more and more proficient using the keyboard. I remapped my Caps Lock key to Ctrl, installed a nice color theme and fell in love with org mode.
After about a month of Emacs usage my touchpad had started collecting dust and I was happily hammering away at my keyboard, confident that I had at last found the one true editor.
Enter Vim
So, I downloaded Vim, got some plug-ins and went cold turkey. I decided I would use Vim for at least a month before I went back to Emacs. However, my stay in Vim-land became much longer than I had expected.
Emacs, while different from most GUI-based editors, doesn't look that unusual at first sight. The first stumbling block for Emacs novices usually doesn't come until they try to save their file by hitting Ctrl-S. Upon failing, there is usually some swearing, followed by even more cursing when they realize that saving is accomplished by entering the combination Ctrl-X-S. Informing them that releasing Ctrl before typing the S results in a different command usually doesn't help. And if you are really unlucky you'll tell them that Ctrl-X U undos, they try it but forget to release Ctrl, and get molested by a prompt that asks them strange questions about something called "uppercase-region". But I digress.
Vim, on the other hand, behaves very differently from GUI-based editors. Incredible as it may seem, it bests Emacs in the grief and confusion department by perplexing beginners from their very first keystroke. Typing in Vim seems to do nothing, or produces completely unexpected results. This is because Vim uses a very different conceptual model - modal editing.
Modal Editing
As an example, hitting the "j" key in Vim will not produce a "j" on the screen, but will instead move the cursor one line down. To insert text, one must enter Vim's insert mode, and then go back to normal mode to access features like moving around in the document, searching, replacing, etcetera.
This way of editing might seem terribly unwieldy at first, but it is incredible powerful once you get used to it. For example, if I want to swap the position of two lines I can just go "ddp" and be done with it. Or, lets say that I want to copy the text inside a pair of square brackets - "yi[" does it.
It was this incredbile editing power that got me hooked on Vim; at last, I thought, I had found the one true editor.
Coming home to Emacs
Having finished the project I realized the Emacs way of text editing wasn't half as bad as I had remembered it. Sure, it felt a bit uncomfortable having to hammer that Control key as if I was telegraphing my source code, but I could live with it. So I said to myself, "Hey, why not give Emacs another shot?". So I did, and it felt a bit like coming home to a warm cup of cocoa.
Emacs VS Vim
Emacs and usability
In Emacs, the buffer switching command lists all buffers, and will highlight them as you type, indicating which buffer it will switch to if you hit Enter. By default, hitting Enter without typing anything will switch back to the last visited buffer, which is often the behaviour you want.
Another example is Emacs' incremental search feature: Typing in the incremental search prompt will highlight all matches in the buffer, with the next match in a different colour. This makes it easier to see where you can jump to, and exactly how many more characters you need to type.
There are more small features like this (for example how emacs defaults to the directory of the current buffer when you open a file), that might seem insignificant by themselves, but they add up to a very pleasurable user experience.
Emacs comes with batteries included. You get a "scratch" buffer for jotting down notes you might want to throw away later. You get an email client, a file browser and if you install OrgMode you get a really cool task management program - all within Emacs. Why would you want to do all of this inside your editor? Because all of these applications are text-driven by nature, and Emacs is made for manipulating text. This is the origin of the phrase "Emacs is a great operating system – the only thing it lacks is a decent editor".
Emacs is also a fully-featured LISP environment, which is the source of much of its power and flexibility. It is fully programmable, and the tight integration with LISP makes it easy to extend or expand upon Emacs' functionality.
When I first tried out editing Python in Vim I was pretty disappointed---line breaks in function calls wouldn't wrap to PEP8 standards, there was no way to toggle comments, sometimes it wouldn't indent blocks properly, etcetera. Of course, there are plugins to address these issues, and others, but in Emacs it just works, right out of the box.
The problem with this whole Emacs vs Vim argument is that both editors are so good. If one of them were crap, its followers would (hopefully) realize the error of their ways. This also leads to a condition known as "editor envy" where Vim users envy Emacs users for things like OrgMode, and Emacs users envy Vim users because their hands haven't turned into claw-like appendages from overuse of modifier keys.
And so, the fervor with which these two camps defend their editors of choice does not stem from a deep inner conviction that they are right; rather, it comes from a nagging doubt that says they might be wrong.
Ironically enough, after writing this blog post and using Emacs at my internship for a week, I started to develop pains in my arms and wrist---the bane of all Emacs users. So, since my plans of switching to Emacs have been foiled it's back to Vim again!
Another example is Emacs' incremental search feature: Typing in the incremental search prompt will highlight all matches in the buffer, with the next match in a different colour. This makes it easier to see where you can jump to, and exactly how many more characters you need to type.
There are more small features like this (for example how emacs defaults to the directory of the current buffer when you open a file), that might seem insignificant by themselves, but they add up to a very pleasurable user experience.
Emacs and utility
Emacs is also a fully-featured LISP environment, which is the source of much of its power and flexibility. It is fully programmable, and the tight integration with LISP makes it easy to extend or expand upon Emacs' functionality.
Emacs and flexibility
Conclusion
And so, the fervor with which these two camps defend their editors of choice does not stem from a deep inner conviction that they are right; rather, it comes from a nagging doubt that says they might be wrong.
Ironically enough, after writing this blog post and using Emacs at my internship for a week, I started to develop pains in my arms and wrist---the bane of all Emacs users. So, since my plans of switching to Emacs have been foiled it's back to Vim again!
The main reason to learn Vi/Vim is that if you are plunked down onto a random Unix box someplace, you'll alway have vi on hand to edit with. This has happened to me. A little vi knowledge goes a long way.
SvaraRaderaTry sticky keys, it's way easier on your wrists. It lets you hit Ctrl, then the key rather than the two together.
SvaraRaderaSet up your Caps Lock key to act as Control. Much easier on the wrists.
SvaraRaderaEvery keypress in emacs triggers a function call. Letter keys trigger self-insert-command by default, but it is straightforward to make them act like they do in vi (http://www.delorie.com/gnu/docs/emacs/viper.html). Assigning a chord to turn viper-mode on and off gives you the best of both worlds and makes emacs the best editor for your needs.
SvaraRaderaAgreed. Xmodmap your pains away. Hopefully you're not on windows.
SvaraRaderaI'd like to mention that Emacs/Vim is a largely unnecessary argument. They are both so powerful now that one can become the other most of the time.
SvaraRaderaAlso, some of your complaints about vim hold weight in that emacs does some of these things better "by default." However, a lot of the preferences you have can be actualized in vim via configuration. For example, vim can absolutely do incremental search with highlighting.
You don't necessarily need to use Emacs/Vim to have a 100% keyboard driven *and* usable editor.
SvaraRaderaI use Kate, plus this little LD_PRELOAD hack: http://pastebin.com/N3tyPFms
(note: Dvorak keyconfig)
I can move my cursor with ALT+jkli (left, down, right, up), ALT+qa (page up, page down), ALT+uo (home, end), ALT+h (backspace), so I effectively don't have to move my hands off the "main keyboard" to edit the text. I also have a handy file switcher on CTRL+1 which works just like the one you've described for Emacs. I once wanted to try to switch to Emacs/Vim, but now - I don't think I will gain anything at all by that, as I have no idea how I can improve my editing experience anymore. (And if I'd knew I would just either extend my LD_PRELOAD hack or extend Kate itself instead of spending a month to learn a dinosaur editor.)
:b shows all my open buffers without typing any part of any buffer names. Maybe you just haven't turned on wildmenu
SvaraRaderavim also has incsearch for incremental searchmatching. It doesn't highlight the "next" word differently though.
Turn on autochdir to make vim "change the current working directory whenever you open a file, switch buffers, delete a buffer or open/close a window."
Install the nerdcommenter plugin to easily comment/uncomment lines in nearly any language.
The biggest advantage I have heard of in favor of emacs is that you can probably write slightly better plugins for it.
Tried ErgoEmacs? No pain for your wrists, but completly rebinds all key mappings
SvaraRadera"I was even less enthusiastic about Eclipse's support for keyboard-only editing. "
SvaraRaderaHave you tried Eclipe's Quick Access (bound to Ctrl-3)?
http://programmers.stackexchange.com/questions/9122/what-features-in-eclipse-is-not-available-in-visual-studio/10151#10151
It allows you to quickly run any command, switch to any view, edit any preference, etc. Just Ctrl-3, and type what you're looking for. It also shows the keyboard shortcuts for the commands, so you can directly use the shortcut later.
Your journey is incomplete.
SvaraRaderaYou now need to go back to Vim, and see if it also feels like a cup of cocoa.
Den här kommentaren har tagits bort av skribenten.
SvaraRaderaI have enabled incsearch and highlighting, but I still can't get it to highlight ALL matches as I type. When I've entered my search, it highlights all matches, but during typing it will only highlight (and jump to) the next match. Am I doing something wrong? Here's the lines I'm using in my .vimrc:
SvaraRaderaset incsearch
set showmatch
set hlsearch
Samu: Thanks for the tip! Now directory switching works the way I want :)
Corrie: Coming back to Vim feels more like being reinitiated into a secret ninja temple where you are forced to tread the path of shadows until you have acquired superhuman speed and agility.
The injury from typing thing is more related to bad keyboard posture than editor.
SvaraRaderaI type more than anyone I know, and I've been a software developer and writer non-stop since 1990, yet I've never even been sore, even after epic days of typing - I've sat at the keyboard for as long as 8-10 hours at a stretch.
The #1 way to prevent strain and/or injury is to be sure that you use proper forearm posture. Your forearm should be in a straight line with your wrist and hand - a good side view of this is here: http://www.merckmanuals.com/home/sec05/ch071/ch071d.html
From above it should be the same. And this is why the Windows-style "Caps Lock to the left of the A" key is so bad for you - Caps Lock is used very rarely compared to CTRL, so you are repeatedly twisting your wrist to use CTRL. Swap the two, and CTRL turns into a slight movement of the pinky.
Anyways, that's my 2 cents :)
Fuzzy finder is more than you need for buffer management => http://www.vim.org/scripts/script.php?script_id=1984
SvaraRaderait does fuzzy matching, so if your filename is foobar_funky.c hitting ,fb+ky.c+Enter would open that buffer (,fb is my keybinding to open fuzzy buffer finder). You can checkout my complete .vimrc with plugins here http://github.com/minhajuddin/dotfiles There are lots of great .vimrc files on github. VIM has some of the most powerful plugins. Checkout this baby => https://github.com/rstacruz/sparkup/ for instance.
"Ctrl-X-S"?
SvaraRaderaAnd people wonder why Windows rules...
vi (vim is an implementation of vi) does not have an "insert mode". It has an "insert command". The distinction is subtle but important. Type "3a1234567890^[" to see the difference.
SvaraRaderaAlso, try nvi as well as vim.