

One with Vim - fredoliveira
http://invisibletheory.com/2011/01/27/one-with-vim/

======
bch
I'm aware I may be too pedantic, but it bothers me when people seem to
completely conflate vim with vi. For example, -vi- was released in 1976, and
vim not until 1991, despite what the article claims. In the meantime, I'll
keep happily using nvi, and keeping the kids off my lawn.

edit: links...

<http://en.wikipedia.org/wiki/Nvi>

<http://en.wikipedia.org/wiki/Vi>

<http://en.wikipedia.org/wiki/Vim_%28text_editor%29>

~~~
tygorius
I think you're going to have to lot further than that to be too pedantic for a
discussion of programming editors.

As a relative latecomer to vim, I think your distinction is worthy
remembering. If you didn't start with vi, it's easy to assume that all the
power and cool stuff is the result of improvements and not realize how much
just plain old vi could/can do.

~~~
bch
About being pedantic, "going a lot further" -- being a pedant is all a
cultural construct, though, isn't it? We're in a time where the lack of
distinction between vim/vi is displayed _so_ often that it's not hard to
imagine a group of people looking at my original comment and saying "to hell
with you, you -are- pedantic, old-school, and vim -is- vi. But better."

I'm really happy there are enough people who apparently appreciate (if not
fully agree with) my comment to upvote it, though. I don't care about the
karma, but happy to see signs of kindred spirits :)

------
powdahound
The Command-T plugin [1] was a big help in switching from TextMate to vim. I
have no idea how anyone can be productive in vim without it (assuming you're
working on a multi-file project).

1\. <https://wincent.com/products/command-t>

~~~
wccrawford
:e .

or

:NERDTree

~~~
stevelosh
I use NERDTree and it's not even remotely close to Command-T (or PeepOpen,
which is pretty much the same thing).

NERDTree is great for browsing your project and _managing_ your files, but for
opening files (when you know their names) you really can't beat the speed of
Command-T/PeepOpen. They're in another league.

I don't know how people work without it.

~~~
ecaradec
I use vim project. I load all my files in the side pane, and I search with /
the file I want to open.

<http://www.vim.org/scripts/script.php?script_id=69>

------
VMG
Vim is my primary editor but I think the only _really_ good part of vim is the
keyboard navigation. The rest could be much better.

For example, to this day I haven't figured out an easy, built-in way to copy
from one vim window to another. I'd love to have some features of other
editors have but the key bindings always hold me back.

~~~
pge
you can copy and paste from the system clipboard as the + register - use "+y
to yank to the system clipboard and "+p to paste from it (depending on OS, you
may need to use * instead of +). This allows cutting and pasting between vim
and other applications (including other instances of vim).

For editing multiple docs with vim, I find it's easier to use multiple buffers
in the same window. Use :b <start of file name> to jump back and forth.

~~~
storborg
I never really liked using :b ... for quickly switching back and forth between
files, so I bound ^hjkl to move among buffers. Perhaps the best part of my vim
experience.

    
    
        " Use ctrl + movement keys to move around windows
        map <C-H> <C-W>h<C-W>_
        map <C-J> <C-W>j<C-W>_
        map <C-K> <C-W>k<C-W>_
        map <C-L> <C-W>l<C-W>_

~~~
Nick_C
1 ctrl-^ go to buffer 1

2 ctrl-^ go to buffer 2

3 ctrl-^ go to buffer 3

ctrl-^ toggle this buffer with the last one, quickly switching back and forth.

[Of course, ctrl-^ is actually just ctrl-6, you don't need to use the shift
key.]

If you have used a tiling window manager before, this is very natural.

------
curiousyogurt
One of the features that really got me into Vim was the macros feature. I
actually ran into in accidentally several times when I was first learning the
basics (and couldn't get out of recording mode). But macros, and especially
the temporary nature of macros, have saved me (collectively) many hours:

q <macrokey> <do some stuff>; then q to stop recording. Then @<macrokey> to
kick off the macro. Splendid.

~~~
David
As a new vim user, I'm still trying to figure out what to do with them.

What do you find yourself macroing, generally?

~~~
alinajaf
For me the most important thing was learning to add a 'j' at the end of each
macro and running it multiple times. So lets say you want to crack open an
array that looks like this:

    
    
        $address = array(
         'name'  => '',
         'line1' => '',
         'line2' => '',
         'state' => '',
         'country' => '',
         'postcode' => '',
        );
    

That's a lot of commas and quotes etc. Nowadays I usually punch this into vim:

    
    
        name
        line1
        line2
        state
        country
        postcode
    

Then I start on the first line and record a macro that wraps that word in
quotes, then appends hashrocket, quotes, comma, and then moves to the next
line. Run the macro 5 times with 5@<register> and the you get your array.

~~~
burgerbrain
If you're a heavy macro user, you might find `:noremap <Space> @q` to be
handy. Just stick your temporary macro in q (the easiest one to stick it in
:), then press the spacebar to run it whenever you want.

------
pge
"been around since 1991"?! while that's probably correct for vim proper, that
ignores the much longer history of vi...

~~~
fredoliveira
you are absolutely right - fixing this now. Vi has been around since the 70s,
but I used the date for vim on the post - which was dumb of me.

~~~
ez77
Please consider bch's comment [1]. Unless you want to write quite a bit more,
I believe you should actually go back to '1991' in your text. While most think
that vim is indeed 'vi improved', there is a fair consensus that vim is not
vi.

[1] <http://news.ycombinator.com/item?id=2149367>

------
octopus
I've used Vim successfully on Windows/Mac/Linux and you can customized it as
you wish.

Interesting post so 1+.

As a side note the font used for the article does not render well on my Chrome
browser. What are you using ? :)

~~~
fredoliveira
really? Damn, it should. It's Meta Pro served by Typekit. Are you on a Mac?

~~~
octopus
I've read your post on Windows, on Mac it looks OK.

------
swah
Vim is easier on the hands, but Emacs (with ido-mode) still feels better for
working with multiple files:

    
    
      (length (remove-if (lambda (b) (not (buffer-file-name b))) (buffer-list)))
      42

~~~
gurraman
There are multiple similar plugins for vim.

~~~
wahnfrieden
FuzzyFinder is great. It's no ido-mode though

------
husted
I've tried to use vim for a while but I've given up pretty quickly. Yes I'm
aware that the learning curve for any new editor is steep but that's not why
I've given up on vim. I do all my source code editing in a Windows environment
and my choice of editor is Source Insight[1]. I haven't found any editor that
allows me to navigate the source three so elegant and fast. I only do embedded
development so I can't speak for it's abilities outside C.

[1] <http://www.sourceinsight.com>

------
TheRealGL
Why does every article about Vim just recently seem to promote it on the Mac
to be used via MacVim? Vim does work in the terminal, and apart from tabs I
can't see what MacVim is bringing to the party?

~~~
adimitrov
Native integration, mostly. I.e. clipboard stuff and a shiny interface. Also,
colors.

Me, I compiled vim over ports and use it via rxvt-unicode or as gvim in an
XQuartz session. That, and I run XMonad in that same session.

This way, my iMac at work almost feels like a Linux machine, and I can at
least get work done here (if I'm not browsing HN.)

------
rimantas
Let me share what I stumbled upon yesterday:
<https://github.com/carlhuda/janus>

------
freakwit
selfish question here: Does anybody know how to setup vim so that :!
recognises aliases?

something like...

    
    
      set shellcmdflag=-O\ expand_aliases\ -c

~~~
Nick_C
I always start vim from within xterm (bashrc has already run and aliases are
already set up). It just works. I can use :!ll (or ctrl-z and 'll' in the sub-
shell) and it just works.

Not sure why it wouldn't for you.

~~~
graywh
ctrl-z doesn't start a sub-shell, it backgrouns vim and returns you to the
parent shell.

And maybe he's running gvim or from a login shell that hasn't sourced his
bashrc.

------
angrycoder
What is the closest you can get to emacs ido mode in vim?

------
zby
I am waiting for the retro-fashion to go back to ed
(<http://www.gnu.org/fun/jokes/ed.msg.html>).

------
georgieporgie
Am I foolish for not believing the vi/vim hype? I understand that it's been
around for as long as rocks, and that it's quite handy since it's available
everywhere. I use it daily, in fact, but rarely for more than basic editing.

I'll just come out and say it: my favorite editor is Visual Studio. Sure, it's
slow to load and rather fat now, but I'm talking solely about the editing
functionality.

With vim, I have to climb an amazing learning curve, regularly practicing all
sorts of commands to achieve basic productivity. With VS, any command I don't
recall is readily available through the menus. As I access it in the menus,
I'm reminded of the keyboard shortcut, so it seems like a much more natural
leaning experience to me.

~~~
ldh
_I'll just come out and say it: my favorite editor is Visual Studio_

Not to be overly pedantic, but your favorite _IDE_ is Visual Studio, and you
just happen to use whatever crappy editor component comes bundled with it.

If we could have full-blown Vim embedded inside IDEs instead of good-but-
incomplete plugins which merely give you some of the key mappings, I'd be
elated and couldn't see why anyone would stick with the Notepad-style editor
which is the default.

~~~
kd5bjo
I never tried to make it work, but the vim distribution for Windows used to
include a COM object which could be used as your Visual Studio editor.

~~~
shadowfox
It works, in a no-frills sort of way. I would much like it if I could get true
embedding though.

~~~
roel_v
Have you tried viemu? It's not real vim in that it doesn't have the plugins
etc. but I haven't missed a single one of them.

