

Why, oh WHY, do those #?@! nutheads use vi? - alex_c
http://www.viemu.com/a-why-vi-vim.html

======
jng
I'm the author of the linked article (and of the ViEmu products). Thank you
guys for taking some time to read it.

The funny thing is that having vi/vim editing inside Visual Studio is bringing
in new converts:

<http://www.jpboodhoo.com/blog/GettinJiggyWithVIM.aspx>

<http://www.jpboodhoo.com/blog/HookedOnVIM.aspx>

Of course I'm not impartial, but I would recommend you consider giving it a
try if you have access to vi, vim, or emulation for them in your IDE (and some
time).

I miss having it in Firefox textareas (such as when typing this comment). I
don't like using an external text editor for this - integration is everything
to me. I'd happily pay for it, and I'm sure others would, too, although of
course it's not a big market. Anyone up to the task?

~~~
LogicHoleFlaw
First, thank you for writing this article. It's the best explanation I've seen
of what vi is all about. I'm pointing several friends at it today to help
explain my vim addiction. Your graphical cheat-sheet is also excellent.
([http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial...](http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html)
for those following along) When I started learning vim I printed it out and
it's still hanging on my cube wall. It really captures a lot of the mnemonics
and helped me get up to speed quickly.

I was forcibly introduced to vi when I was doing some system administration on
some AIX machines. Emacs was not available and I'm not even sure if something
as simple as pico was. Since I was going to be doing a lot of work on these
boxes I decided to learn vi. It was one of the best computing decisions I've
ever made. I've been using vim for about two years now and everything has just
become instinctive. When I'm using another editor I just feel crippled. I
still feel like there's a lot I can still learn - I try to pick up a new trick
at least once a week.

Here's my current list of tricks from my .vimrc file. I still tweak it but
it's pretty stable these days.

    
    
      " enable vim goodies
      set nocompatible
    
      " tab policy: spaces only, 4 per indentation level
      " (company policy, don't flame me)
      " use language-sensitive indentation where available
      " use :retab to fix nonconforming files
      set tabstop=4
      set shiftwidth=4
      set shiftround
      set expandtab
      set smarttab
    
      " use syntax highlighting
      filetype on
      syntax enable
    
      " use auto-indentation
      set cindent
      set ai
      set number
    
      " misc options
      set matchpairs+=<:>  " bounce matching angle brackets on %
      set hidden           " don't kill buffers, just hide them
      set incsearch        " incrementally search (firefox does this too)
      set ignorecase       " ignore capitalization when searching
      set scrolloff=5      " scroll the screen to keep the cursor more than 5 lines in
      set showbreak=\      " display wrapped lines with a leading '\'
      set breakat-=-       " allow wrapping words at '-'
      set linebreak        " allow word wrapping
    
      " colorscheme desert   " previous favorite colorscheme
      colorscheme vibrantink " current colorscheme borrowed from textmate
    
      " include arc support (via plugin from the anarki)
      au bufnewfile,bufread   *.arc   set ft=arc
    
      " show all matching files when expanding wildcards
      set wildmode=longest,list
    
      " don't display the graphical toolbar (it annoys me)
      set guioptions-=T
    
      " ********** Custom Keybindings ********************
      " CTRL-k and CTRL-k move the current line up or down
      nmap <silent> <C-j> :m+<CR>
      nmap <silent> <C-k> :m-2<CR>
      imap <silent> <C-j> <C-O>:m+<CR><C-O>
      imap <silent> <C-k> <C-O>:m-2<CR><C-O>
    
      " backwards-kill-word idea cribbed from Steve Yegge
      " hit CTRL-h (insert and normal mode) to delete the word
      " you are currently typing. It's faster than backspacing.
      nmap <silent> <C-h> ciw
      map! <silent> <C-h> <Esc>ciw
    
      " hit F1 to toggle match highlighting
      map <F1> :set invhlsearch<CR>
    
      " linux friendly: paste the current X selection on middle mouse button
      map <S-Insert> <MiddleMouse>
      map! <S-Insert> <MiddleMouse>
    
      " ************* Load Plugins *****************
      " start matchit
      source $VIMRUNTIME/macros/matchit.vim
    
      " Toggle the TagList
      nnoremap <silent> <F8> :TlistToggle<CR>
      let Tlist_GainFocus_On_ToggleOpen = 1
      let Tlist_Exit_OnlyWindow = 1
      let Tlist_Use_SingleClick = 1
      let Tlist_Process_File_Always = 1
    
      " Toggle BufExplorer
      map <F9> \bs
      let g:bufExplorerShowDirectories=0   " Don't show directories.
      let g:bufExplorerSplitBelow=1        " Split new window below current
      let g:bufExplorerSplitHorzSize=0     " Use this many lines for the window
      let g:bufExplorerUseCurrentWindow=1  " Open using current window

~~~
jng
Thanks for your kind comment! I'm glad the article and cheat sheet are useful
and appreciated.

I got started with vi(m) about 3 years ago. I did actually do some development
on AIX over 10 years ago (that system looked like a washing machine!), but I
didn't get hooked with vi(m) until I really did a lot of development on a
laptop with horrible keys:

<http://blog.ngedit.com/2005/06/03/the-vi-input-model/>

Your .vimrc is much more complex than mine! But very nice in any case, I
should steal a trick or two from there.

A detail I remember about the AIX system headers: their math.h defined a
function called 'class'. I had to do some #defining around that to get them to
work with the C++ compiler! It was '96 or so, so they should have taken C++
into account already. Duh. At least it wasn't as horrible as windows.h and its
accomplices.

------
mechanical_fish
This article is excellent. I'm an emacs user, and I know of several articles
and books that introduce emacs, but this is the first time that I've ever
actually understood how a vi master thinks.

~~~
whacked_new
Wow, the '.' is certainly an enviable feature.

[http://meghnad.iucaa.ernet.in/intranet/sysadm/help_desk/emac...](http://meghnad.iucaa.ernet.in/intranet/sysadm/help_desk/emacs/49.html)
isn't reassuring either. How does C-x (, C-x ), and C-x e compare?

<http://linuxgazette.net/issue47/pedersen.html>

~~~
mechanical_fish
The emacs macro features compare _pretty_ well. They're a killer feature of
emacs. The editor is named after macros, after all.

You can probably accomplish much of what vi's "." does using emacs macros. The
trick is that in emacs you have to notice the opportunity slightly in advance,
so that you can hit 'C-x (' and then plan out your macro so that it plays back
well on subsequent invocations. You could probably train yourself to think of
that more often, after which your emacs experience might be roughly similar to
that of the vi user.

But I suspect that vi is better designed for such a macro-intensive style of
editing. The beauty of "." appears to be that vi workflow _naturally_ divides
into little chunks of action, each of which can then be treated _post facto_
as a macro. This explains my #1 pet peeve as a completely ignorant vi user --
that vi is so damned choppy, always switching in and out of insert mode.
That's not a bug, it's a feature! Those little transitions are the waypoints
that will later be used to break your workstream into repeatable chunks.

------
brk
Awesome! I've been using vi for about 14 years now and am still learning new
shortcuts and ways to harness the power of vi.

I love vi for its combined power and simplicity. It is installed by default on
almost every terminal I've ever walked up to, all flavors of nix, BSD, HP-UX,
etc. seem to come happily installed with vi ready to go.

~~~
chrisbroadfoot
Man, I agree with the notion of power, but I simply cannot see how anyone
could call it simple. The array of keystrokes and their combined meanings is
not anywhere near simple, in my opinion.

That said, I would really like to _sit down_ and learn vi sometime.

~~~
tokipin
about the longest 'combos' you make are action-move combos, which is 2 keys,
and both the actions and move keys do things by themselves. 'w' for example
moves to the beginning of the next word. it's a common travel key. 'dd'
deletes the current line and is also commonly used. combine them into 'dw' and
you delete everything up to the front of next word

so you preface any motion command with an action and you get the intended
effect. it's a lot more intuitive than it may look at first. a combo i use a
lot is 'cw', which replaces the current word. but when programming this is
equivalent to "replace variable." it's things like that (see the 'smart
ranges' topic on that link) that make it feel like you're more directly
connected with the code, rather than editing it through an interface

~~~
chrisbroadfoot
As I say, I do love the power of it and I'm sure I'd find it somewhat
intuitive once I start using it, but it's just a steep learning curve when you
can't fall back to input with a mouse.

What I mean is: whenever I start learning a new program, I like to be able to
use it like a n00b at first (i.e. click around, use native controls), and then
learn the more powerful features.

A good example of this way of learning is the way I use TextMate... every day
I learn new controls, and get more proficient and more effective, but I'm not
rendered useless (as one would be with vi) if I don't know each and every key
combination.

Granted, you can make do with just a few vi commands and be not effective at
all, but it's not the same as using a GUI

~~~
brk
Interesting perspective, I'm wondering if you're a "Gen Y'er" (or whatever
they're calling that newfangled generation these days ;)

I ask because I started with PCs before the mouse was really commercialized.
My first programs were on Commodore PETs and C64 and my PCjr. (Although I did
later buy a mouse for the PCjr, I think it cost close to $200 at Babbages, had
to save money for a while for that one...)

My long-winded point being that I "grew up" with a CLI. We edited our text
files with edlin (and we liked it, dammit!!). Maybe the folks who didn't get
started viewing the mouse as a primary interaction device feel more
comfortable with vi, and never really missed the mouse interface.

~~~
LogicHoleFlaw
_I'm wondering if you're a "Gen Y'er" (or whatever they're calling that
newfangled generation these days ;)_

Apparently the defining starting birth year for that generation is 1982. I
happen to have been born that year, and my preferred term for the generation
is "Millennials". "Gen Y" over-emphasizes our interaction with the "slacker
generation" which preceded us.

Anyway, I don't think that there's much correlation between birth year and vi.
With the rise to prominence of Linux and other Unix systems many many budding
hackers are starting out with full-fledged command lines and honest-to-
goodness Unix. And that's a beautiful thing.

------
brentr
My experience with vim started when I got OS X. I had always wanted to learn
how to use the terminal on a UNIX machine, and as an extension of that want, I
learned to use vim as it was very easy to jump right into it from the
terminal.

If there was one word that I could use to describe vim, I would have to say:
beautiful.

------
wfarr
Being a dedicated emacs user, I could only shake my head and sigh as I read
this.

~~~
SwellJoe
The first step is admitting you have a problem. You're on the right track.

~~~
hooande
I would love to get into a lengthy discussion about why the One True Editor is
superior to vi, but I have a feeling that it would just degenerate into a
flame war. vi does have an advantage in that it comes standard on most unix
servers, while emacs requires a long (but relatively painless) install.

Let's just say that in terms of power the two are about equal. I think emacs
has an edge in the macros/functions department but vi isn't far behind. It's
probably also fair to say that either one of them are probably better than a
Windows based IDE if you're working with open source software (ruby, php, perl
etc).

~~~
SwellJoe
I'm sorry, I can't hear you over the sound of how awesome my text editor is.

------
hernan7
An oldie but a goodie.

Back when I started working on Unix (early 90s), the only editor on the lab
machines vi. The learning curve was horrible, but after that I never was able
to use an editor for human beings again.

Nowadays, when I'm trapped in a Notepad derivative, it's all jjjjjjkkkkkkwwwww
for the love of God Montesor, give me back my dot!!!

------
acrylicist
Does anyone else resort to writing vi commands down on paper when they are
writing in pen or have no eraser for corrections?

------
tel
Is there any article like this specific to lisp? What really turned me on to
Emacs was learning about Slime, largely through Marco Baringer's videos
(they're linked from this post: <http://bc.tech.coop/blog/050728.html>)

------
god
The only problem I see with vim is that today I write everything online. In
textboxes like the one I use right now to type this text. Maybe we need a
firefox extension, that blows up a textarea fullscreen and edits it with vim?

~~~
jlg
Try Mozex.

~~~
bootload
_"... Try Mozex ..."_

Wow I'm editing with it now & it works well. Some observations:

\- It would be nice if it was just concentrated on editing.

\- Certainly a much nicer alternative than the textbox

\- miss the spelling syntax highlighting

\- It doesn't appear to allow you to edit in the textbox after editing :(

\- you need to :wq! & hit enter to save

Can be found at <http://mozex.mozdev.org/development.html>

------
marrone
I switched to vim for a few reasons:

\- I didn't want to get trapped into being comfortable with some editor that I
would later not have access to. vim will always be there on any unix box

\- there are no showstoppers for vim. Every other editor is great because it
has x and y, but the lack of z is annoying. with vim, you can configure it to
do almost anything with macros in your .vimrc

\- it was slow to get going at first, but now I find using vim you can edit
files much faster than using the mouse.

~~~
davidw
vi might be on any unix box, but not vim.

~~~
SwellJoe
That's true. I'm working on FreeBSD support in our products right now, and
every time I type "vi filename", I either get frustrated as hell for the few
bits of typing I have to do, or I notice immediately and :q and "vim filename"
to get the right thing. Since I'm spawning new instances for each testing
cycle (I'm building a product installer) it's a bit of a nuisance to make an
alias each time. The default csh shell also pisses me off.

------
rumblerob
Someone should tell them that their "VI Gang Sign" is a pretty close analogue
of the Shocker. (Not that that couldn't be a convincing argument to learn
vi...)

~~~
derefr
They already know (search for "the Shocker"):
<http://blog.ngedit.com/2007/11/19/the-vi-gang-sign/>

------
ten-seven
Back when I was coding a lot, there were two editors, vi and one other that
came with the Unix variant we had. The other "visual" editor had an annoying
tendency to convert multiple spaces to tabs if it was able to. This broke
formatting and messed up make files. It sparked a holy war against those who
"maintained" code with that editor, calling for those people to use vi and
stop breaking things.

------
meat-eater
I work equally well in vi and emacs. Now I've switched from emacs to textmate,
but still use vi for editing config files. It's just how I work, vi for config
files, another editor for code. Of course, I also use vi to write short
scripts on the server. I've been using vi for over 10 years, but this article
showed me why it might be a good idea to edit code with it.

------
noonespecial
Why I like vi/vim.

Its always there. Even on tiny linux distros.

It allows me to operate just as fast on _extremely_ high latency connections.
It was the only usable editor when I was stuck with 650ms+ latencies on VSAT.

------
Hexstream
hjkl motion is retarded on anything but a qwerty layout :/

~~~
demallien
works just fine on my azerty keyboard....

~~~
Hexstream
I know, I consider that's in the qwerty group, mind you. Especially since the
hjkl keys are at the same place than on qwerty, so your "clever" remark is
irrelevant.

------
NonEUCitizen
re: newbies, must be gmail's fault for adopting vi keybindings. e.g. j to
navigate down and k to navigate up (in "list view").

~~~
graywh
Google Reader, too.

------
sabat
Confession: I use vi because when I was learning how to be a sysadmin (was
already a coder) it was recommended -- back then (the '90s) you never knew if
emacs was going to be on a system, but vi was practically guaranteed.

I still barely know how to use it, though: my own fault. Laziness prevails.
Some of the commands I use because I discovered them by accident (shift-C
erases the rest of the line and puts you into edit mode -- I figured that one
out because of a typo).

~~~
kmt
Does this mean that nowadays you can expect emacs to be installed on every
system? From what I've seen, still no. So basic vi skills are still needed.
But nowadays, there are many ways to avoid having to edit files with vi. If a
system has sftp access you can mount it's file system via sshfs and edit files
from your main machine in emacs. This way you could even have the files
version controlled on your main machine. There's also tramp mode of course,
but sshfs works better.

~~~
LogicHoleFlaw
When you really need vi, you _really_ need it. I'm talking about connecting to
servers halfway around the world with the only access being via a serial
connection. Straight-up serial console, none of this fancy newfangled terminal
emulator nonsense. No amount of emacs and sshfs will help you then.

