News for hackers. Stuff that matters.
Re:Learning vi -- the "cheatsheet" technique by bostondjango on Saturday January 31, 2009 @04:21PM (#460068)
I was a fake vi user for a few years before I finally decided to sit down and learn it. What helped me get into the "feel" of vi was finally disabling my arrow-keys and forcing myself to use the hjkl keys for movement. It will suck for the first few weeks but eventually you'll notice a significant increase in productivity. Throw this into your .vimrc:

map <Left> <nop>

map! <left> <nop>

map <right> <nop>

map! <right> <nop>

map <up> <nop>

map! <up> <nop>

map <down> <nop>

map! <down> <nop>

Re:Learning vi -- the "cheatsheet" technique by GHFigs on Saturday January 31, 2009 @04:55PM (#460121)
NetHack (or Angband, et al.) is another great way to learn hjkl. I can't say you'll notice a significant increase in productivity, but you'll at least get accustomed to the keys.
Re:Learning vi -- the "cheatsheet" technique by mapleoin on Sunday February 01, 2009 @01:51AM (#460645)
or wmii/dwm/xmonad/awesome to a somewhat lesser extent
Re:Learning vi -- the "cheatsheet" technique by rw on Saturday January 31, 2009 @04:54PM (#460117)
Is it possible to use hjkl in command-mode?
Re:Learning vi -- the "cheatsheet" technique by bostondjango on Saturday January 31, 2009 @04:59PM (#460130)
Yep. I use it all the time.
Re:Learning vi -- the "cheatsheet" technique by babo on Saturday January 31, 2009 @02:13PM (#459927)
"There are many versions of vi, and I'm going to be showing you how to use a version of vi called vim." Is there any other clone still under active development? Long years ago Vim won, hands down.
Re:Learning vi -- the "cheatsheet" technique by mechanical_fish on Saturday January 31, 2009 @02:40PM (#459957)
But nobody talks about GNU Emacs and vim. They say emacs and vi.

When I log into a server and I want an editor I type vi, not vim. Because vi has worked for twenty years, and I assume it always will work!

(That's actually why I bothered to learn a little bit about vi -- it is always there, on every Unix box, and it always works the same way -- no wacky transposition of Meta keys, etc. On my own machines I use nothing but emacs. ;)

Re:Learning vi -- the "cheatsheet" technique by sjs382 on Saturday January 31, 2009 @03:36PM (#460013)
That's exactly why I learned to use vi, too.
Re:Learning vi -- the "cheatsheet" technique by Dobbs on Saturday January 31, 2009 @02:34PM (#459951)
Many Unix systems (generally the traditionalists) will include vi (as in the standard non-vim vi). Vim is then an added package that can be installed if you wish. There are also several other vi based/cloned like nvi which some Unix systems include. Vim I guess won in that its whats used for the day to day of text editing.

Vim did not win in that its a large package and users are often forced to use a lighter wieght vi clone to admin directly a on server machine.

ps. how do you write a * followed by text?

Re:Learning vi -- the "cheatsheet" technique by silentbicycle on Saturday January 31, 2009 @09:38PM (#460408)
If you add a space after the * it will be fine.

Text surrounded by stars will become italic, though.

Re:Learning vi -- the "cheatsheet" technique by dmm on Saturday January 31, 2009 @02:53PM (#459973)
nvi is the default vi on the bsds.
Re:Learning vi -- the "cheatsheet" technique by karim on Sunday February 01, 2009 @02:56AM (#460685)
there's still elvis, which is shipped by default on slackware. And there's vile (http://invisible-island.net/vile/) too, a clone that handles buffers better (imo) than vim.
Re:Learning vi -- the "cheatsheet" technique by access_denied on Sunday February 01, 2009 @04:01AM (#460719)
Yes, viper mode for emacs ;-)
Re:Learning vi -- the "cheatsheet" technique by mct on Sunday February 01, 2009 @04:29AM (#460737)
Sadly, viper-mode behaves more like a poor nvi clone than a featureful vim clone.
Re:Learning vi -- the "cheatsheet" technique by d0mine on Sunday February 01, 2009 @06:07AM (#460787)
Re:Learning vi -- the "cheatsheet" technique by mct on Sunday February 01, 2009 @04:55AM (#460748)
Perhaps I'm biased because it's how I first learned vi ~15 years ago, but I still think the best way to learn vi(m) is by running vimtutor. It copies the tutorial text file to /tmp and launches vim against it. The text first teaches the user how to move the cursor around (in order to scroll down to the next lesson), then how to exit the editor, and finally different ways of modifying text. Many lessons are followed by interactive examples, which is a really neat way to learn (e.g., "Make the second line below look like the first line").

Text of the tutorial: http://ftp.vim.org/vim/runtime/tutor/tutor

Re:Learning vi -- the "cheatsheet" technique by doki_pen on Sunday February 01, 2009 @09:58AM (#460889)
Since I've begun using a tiling window manager(wmii, in my case), I find it incredibly annoying when programs try to manage their own windows. I find this is often to make up for the deficiencies of most window managers. I want one way to manage windows for all my applications. I still use tabs in firefox though :P
Re:Learning vi -- the "cheatsheet" technique by RiderOfGiraffes on Saturday January 31, 2009 @03:03PM (#459981)
I'm disappointed. I guess I'm not the intended audience, but I was hoping to learn about the windowing operations. The simple stuff in this "cheatsheet" is stuff anyone other than a complete beginner will use absolutely all the time. Windowing makes vi fantastic - I need to learn it.

Note to self: Learn the windowing operations in vi.

Ctrl-p and Ctrl-n are the truly awesome commands for programmers.

Re:Learning vi -- the "cheatsheet" technique by brianto2010 on Saturday January 31, 2009 @04:51PM (#460107)
Try reading the help section on windowing:

  :help window
Here are some basics:

Split to a new file (create a new window)

  :split  [file]
  :vsplit [file]
Switch windows

  C-w [movement-key]
  C-w C-w
Resizing windows (w/o mouse)

  C-w [row-size] _
  C-w [col-size] |
Here is a tutorial that has stuff on windows and tabs (if you want) (pdf):

http://research.iiit.ac.in/~smr/data/advanced_vim_tutorial.p...

This is for Vim, though. I'm not sure if it will work for Vi.

> The simple stuff in this "cheatsheet" is stuff anyone other than a complete beginner will use absolutely all the time.

Not exactly...

Over time, as you memorize commands, you'll gradually become less and less dependent on the cheat sheet.

Even so, I doubt that this will work. I started using Vim by learning one or two commands at a time, not a whole bunch at once, and it worked for me. I believe that a beginner would use this cheat sheet as a crutch because the beginner would use it "absolutely all the time."

Dumb question, but how do we know exactly if it works or not? It didn't cite any test cases. Did anybody try this?

Re:Learning vi -- the "cheatsheet" technique by RiderOfGiraffes on Saturday January 31, 2009 @04:57PM (#460125)
Thank you for the reference. I find the built-in "help" stuff in vi deeply frustrating, because I can't navigate until I learn its navigation commands, and it gives me no way to learn the navigation commands other than by navigating around inside the help system. I'll try again with your suggested reference(s).

With regards this last point though, I don't seem to have expressed myself clearly. My point is that the material covered in this "cheatsheet" page is very, very basic stuff, and if you use vi more than an hour a day then you'll no longer need the cheatsheet within 72 hours. There's little point in having a cheatsheet on the utter basics. Much better to have a cheatsheet on the next level, covering things you only use occasionally, and hence might not remember.

In short, I think we agree.

Re:Learning vi -- the "cheatsheet" technique by 10ren on Saturday January 31, 2009 @09:26PM (#460394)
I find the vim help profoundly unhelpful (unless you already know about the command you need...) Googling (or searching on vim.org) fills this gap a bit.

The main navigating commands are: Ctrl-] (on a "hyperlinked" word) - and Ctrl-t to retrace your path.

Re:Learning vi -- the "cheatsheet" technique by 10ren on Saturday January 31, 2009 @09:16PM (#460384)
Agree. In the same situation: Ctrl-x-Ctrl-f for filename completion.

I recently discovered that Ctrl-p and Ctrl-n will also work across files, if vim knows about them:

  vi file1 file2 file3
BTW: I learnt all the windowing commands at one time, but never really used them (and now forgotten). Instead, I use Ctrl-6 to swap between files, and I remapped Ctrl-p and -n to flick through files quickly:

  :map <C-n> <Esc>:n<CR>		" next file, with control-n
  :map <C-p> <Esc>:N<CR>		" prev file, with control-p
I also use alt-tab to switch between xterms (downside is you can't cut-n-paste with y and p between them).