
Vim is hard, I just want to click around - jkreeftmeijer
http://jeffkreeftmeijer.com/2011/vim-is-hard-i-just-want-to-click-around/
======
thristian
I've always been a little puzzled by people who use a file-drawer or file-list
or similar addon with Vim, and I now I think I know why: I'm guessing most of
these people have Vim open as their One Tool, much like another programmer
might have Xcode or Visual Studio open as their One Tool, and they want to get
everything done in it.

At work, I usually have at least two windows open at all times: Vim full-
screen on one monitor, a terminal full-screen on the other—or sometimes one
terminal taking up most of the screen and another smaller terminal tailing a
logfile. The Vim window gets used for editing (of course), the terminal is
used for running test suites and exploring the codebase and finding and
opening files in Vim. The reason I've never felt the need for a file-browser
plugin in Vim is because I've always used Vim with an external file-browser.
:)

If anyone's interested in opening files in an existing gvim window from the
terminal, here's the script I use in Linux:

    
    
        gvim -f --remote-tab-silent "$@" &
    

(I believe MacVim comes with a similar 'mvim' script you can use on OS X) If
you don't want files to open in tabs, change "remote-tab-silent" to "remote-
silent". If you call the script and there's no existing gvim window, a new one
will be created.

~~~
JoshTriplett
Unfortunately, the remote features require a GUI version of vim. Personally, I
prefer to run vim in a tab of my terminal.

~~~
thristian
The remote features require a version of Vim with GUI features compiled in,
but you don't have to _run_ vim in GUI mode to use them. The only difference
is that when started in console mode, Vim won't register itself as a server
unless it's explicitly told to use a particular server name:

    
    
        vim --servername FOO
    

If you start vim in another tab with the same servername, you can open files
in the first Vim, no problem:

    
    
        vim --servername FOO --remote-tab ~/.bashrc

~~~
JoshTriplett
> The remote features require a version of Vim with GUI features compiled in,
> but you don't have to run vim in GUI mode to use them.

You do have to have an X server available though; the client/server
communication occurs via X.

------
daleharvey
I have a hard time watching people traditionally navigate filetrees and tabs

with emacs and ido-mode enabled I press Ctrl+X B to open a buffer, Ctrl+X F to
open a file, I typically type 2 or 3 characters from the filename and emacs
gives me a list of matches (with autocomplete), usually the first suggestion
is correct and I press return to open the file.

I barely need to think while I do this, there is no visual clutter on my
screen, and I can usually finish the before someone could take their hand from
the keyboard to the mouse and move to the filetree

~~~
wahnfrieden
The (admittedly not as good) equivalent to ido-mode in vim is FuzzyFinder.

~~~
edanm
One of the biggest shortcomings of vim is the lack of a good ido-mode style
file-opener. People seem to rave about command-t, although getting it set up
on Windows proved too annoying for me.

FuzzyFinder is nice, but graphically it's a mess. Like everything else in vim,
really.

~~~
jrockway
This is the biggest meta-shortcoming of vim: the fact that it doesn't come
with a built-in programming language. This forces extension authors to bring
their own, with the expected consequences.

~~~
adgar
It has vimscript, but vimscript is at best emacs-lisp's inbred nephew who is
just as old but huffs glue and has sex with chickens.

~~~
gnosis
Actually, you can also use mzscheme, perl, python, ruby, and lua to script
vim.

~~~
esk
Indeed, but that's what the grandparent is saying—you need to bring your own
language to the party.

------
kragen
Reposting this for horseshoes; it seems to have been mysteriously censored.

Getting familiar with GNU screen and within vim, liberal use of :tabnew foo
got me to prefer a terminal emulator for working and notes over eclipse /
gedit / nautilus. (gt and gT move to different tabs and :tabm N moves the
current tab to tab N btw). If from within vim you :mksession bar.vim, vim
saves all your open tabs so you can :wqall and open the tabs again from the
shell with vim -S bar.vim

Like seemingly everyone, I organize projects into project/doc, project/src,
project/data, project/bin etc. For example, I have a start.vim each in
project/doc and project/src.

Then I put lines in ~/.screenrc

    
    
      chdir /home/horseshoes/workin/myproject/doc
      screen -t myproject_doc vim -S start.vim
      chdir /home/horseshoes/workin/myproject/src
      screen -t myproject_src vim -S start.vim
      screen -t bash bash
    

When I start screen it automatically opens one window containing a vim sesh
with all my most-looked-at documentation tabs (so I can refer to wth I was
thinking and organize my mental pushdown stack a little), one window
containing a sesh for the source files I currently work on, and a third window
holds a shell so I can look for and alter other files or start sqlite3 or make
or w/e.

The point is it fires up work for me so I just have to open a terminal and
type screen and it's instantly ready compared to opening eclipse or visual
studio and then navigating to the relevant related notes and documents, or
cluttering up the place with a billion (or even 2 or 3) terminal emulators,
since screen multiplexes them. I also like to have screen windows open with
cmus (music) and a python interpreter (my calculator and preferred random
'what to make for dinner' decision maker).

I also prefer the command-line environment for programming and also most
general use because of the kool tools it's full of you are no doubt very
acquainted with (ls, locate, grep, less, ps, pipes et al).

(End of mysteriously censored post.)

I have no idea why this might have been censored. Maybe it's the obnoxious use
of "w/e" as an abbreviation for "whatever"?

~~~
burgerbrain
horseshoes is hellbanned for this comment:
<http://news.ycombinator.com/item?id=2928894>

This is why I browse with dead comments enabled. A single particularly poor
comment is a rather inaccurate indicator of future comment quality.

~~~
cookiecaper
Certainly some moderation is appropriate for that comment, but I think a
permanent invisiban is a bit of an overreaction to that. Does this kind of
thing happen frequently?

~~~
silentbicycle
Yes, more so than you might think. Another showdead user.

------
superalloy
A lot of people miss the issue of browsing through projects that you aren’t
familiar with. Auto-completing/fuzzy matching takes more time than actual
browsing in such a case, because you’re probably guessing half of the time.
Maybe it’s just me, but I find that to be annoying within a minute.

------
jackkinsella
VIM defender rushing in. I wrote a post which translates 100 Textmate features
into VIM, and vice-versa. In particular, I included a section on getting used
to the NERDTree.

<http://www.jackkinsella.ie/2011/09/05/textmate-to-vim.html>

------
yuvipanda
Command-T[1] solved this 'problem' for me very nicely.

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

~~~
adriand
I agree completely about Command-T. I don't use any type of file drawer at
all, I tried NerdTree and found it really annoying. The way I see it, you
either know where something is already, in which case Command-T does the job,
or you don't, in which case you may as well use a console, or just use :edit .
in vim to open up the file & folder browser to start browsing around.

Command-T forces you to think: where is this file? And then you type in a
handful of characters and retrieve it immediately. To me, that is very vim-
like, because it's similar to the editing experience, where you think: what is
the most efficient way to do X?

------
nicksergeant
Surprised PeepOpen hasn't been mentioned yet. I use it exclusively with MacVim
on OSX. It is a bit unconventional but works amazingly well:
<http://peepcode.com/products/peepopen>

~~~
devth
PeepOpen is the main reason I use MacVim. So excellent.

~~~
samdalton
I have struggled for a while to get PeepOpen and MacVim working together. I
can run :PeepOpen, and it will switch to the running peepopen application, but
it doesn't load up with the project files. I've tried all sorts of .vimrc
config settings that the internet has to offer, but none worked.

What's in your config for it?

~~~
devth
I actually don't have any .vimrc config for PeepOpen. :cd into your project
directory and use the shortcut (I changed my shortcut to cmd+t).

In MacVim preferences, I set "Open files from applications" to "in the current
window / and set the arglist"

------
lordlarm
I too wanted to click around the first month (+/-) after switching to vim, I
think we all did.

However, it seems like the author learned the basics of vim, but stopped
before he learned about powerful navigation keys, visual mode etc.

I think the moral is: if you feel you don't get the hang of vim/nerdtree etc.,
don't give up - keep going, there is a reason why so many people use it.

~~~
gbog
> don't give up

Yes. All the tutos I have read recently insist on using hjkl, which is a
matter of taste, but do not emphasize what I believe is the most important
(for terminal use): cut and paste.

\- Easy cut and paste in Vim is done with yy and p, avoid mouse and ctrl-c/v
or any other trick that is not "inside" Vim.

\- Good trick are to first select a block with <shift-V>.

\- Don't forget P, which is pasting above current line or before cursor, often
more logical than p.

\- This implies to open different files inside the same Vim instance, using
:Explore or :edit

\- If you have to copy some outside text inside Vim, by all means, use the
paste mode (:set paste), if you don't you'll mess up your text.

~~~
shadowfiend
Also worth remembering is that _every command that deletes really cuts_. Which
is to say, deletion commands like x and dd store the deleted content in the
register that will be used when you hit p or P. This is important to know both
because it can be _very_ useful sometimes and because it can get in your way
other times (e.g., if you're trying to repeat an action and keep replacing a
line with another line, you'll have to paste before you delete so you don't
override your register).

~~~
graywh
Or you can specify the register name. Don't limit yourself to the unnamed
register.

~~~
shadowfiend
Absolutely. My fault for not mentioning it :)

------
shadowfiend
I've been playing around with vico for a couple of days
(<http://vicoapp.com/>) and it seems pretty nifty in terms of solving some of
these from-textmate-to-vim "problems". It uses TextMate bundles and supports
them reasonably well as far as I can see. It also has Cmd-T and is very much a
native app rather than a wrapper around a terminal app, which is more what
MacVim tends to look like (it's what I've been using for the couple of years
since I switched to Mac).

There are some holes in the vi commands that I use; some of them can be filled
in (I'm working on some of the ones I'm missing), some of them will probably
have to wait for official work, but either way I'll probably keep using it for
a few days and see how things feel at the end.

------
phaylon
I'm working on a Gtk2 application that basically solves the same problem. It
adds a sidebar with things like a file browser to a GVim editor. For getting a
feel for a foreign codebase I find it much easier to use something like this
than to switch between navigation/file view all the time.

I tried plugins like NERDTree, which are awesome in one way because they work
everywhere vim works (like in the terminal). However, I didn't really like
their feel in combination with GVim and tabs.

------
JFrolich
I created a fork of janus that removes NERDTree from the distribution just for
using it with alloy's fork. Also some other nice textmate behavior like
quote/brace completion is included. So to get started immediately you can use
it too, it is on github: <https://github.com/JFrolich/janus>

~~~
whalesalad
Thanks, giving this a shot now.

------
jarin
I still click around in MacVim sometimes (mostly for navigating deep NERDtree
hierarchies and for selecting text within a line).

It's all about what's going to be fastest and take the least amount of mental
context switching. I didn't choose vim because it's so hard to move to the
mouse occasionally, I chose it because some things are much faster/easier than
in TextMate, and for some things the mouse is still faster.

Sure, from a purist point of view it's terrible, but I think vim mastery has
diminishing returns at some point (granted, it's a pretty far point up the
learning curve).

------
cturner
The author mentions trying to get around this with the nerdtree plugin. I stay
away from heavy plugins like this because I think they compete with the
minimalism that is so nice to the feel of vi. But I can see why you'd be
attracted to it given the difficulty of dealing with multiple files.

I do this to get nice access to multiple files:

    
    
        set hidden         " allows files to be opened in background
        nmap <C-j> :bp<CR> " edit prev file with ctrl+j
        nmap <C-l> :bn<CR> " edit next file with ctrl+l
    

(goes in $HOME/.vimrc)

~~~
wahnfrieden
FuzzyFinder is the easiest file and buffer navigation plugin I've found. You
should try it. Fuzzy matching is better than having to keep track of what
files you have open and in what order.

~~~
oinksoft
:b completes on path.

I found FuzzyFinder slow and it interrupted my workflow.

~~~
wahnfrieden
It is slow when it has to first index your files, yeah. Path completion is not
really comparable.

------
njharman
The times I open new file vs times :e line is already in my vim/bash history
is tiny. And that tiny amount is handled fine by vim's filename completion.

There seems to be a big divide in usage between gui vim'ers who are probably
doing one window/ide thing vs terminal vim'ers who probably have multiple
terms/vim's open and use unix/cmd line as their die.

Note I make value judgment as to which is better (I'm sure people vary and so
should their tools). My point is you should figure out which one you are and
filter vim suggestions appropriately

------
st3fan
There is nothing wrong with being more productive with a tool like TextMate
instead of vim, emacs or whatever IDE or editor. You should simply use a tool
that works you.

------
mun2mun
I don't get it. When I am working on a project I just go to the root project
directory and open up vim. NERDTree automatically loads the file structure of
the project directory which is my current focus. Why should I need a file-
drawer with the unnecessary folders showing?

~~~
superalloy
You don’t “should” anything. If you don’t feel the need, then don’t install
it.

~~~
mun2mun
A bit harsh response I think. Sorry I did not get my word right. But can you
explain why it is useful to you?

~~~
superalloy
My response wasn't meant as harsh, it just lacked a smiley ;)

I work on a lot of OSS projects and our company does consultancy. This means I
browse other’s projects on a daily basis (i.e. I don’t know the filenames
yet). That, combined with the fact that I have a deep love for GUI design and
platform consistency, has made me come to the conclusion that something like
NERDTree wasn't working for me. I tried to keep on going for a few more weeks,
but in the end I decided that writing a file browser would cost me less time
than I lost during these few weeks.

I’m glad I wrote it, because now I’m perfectly happy with my MacVim setup,
which I wasn't before. I’m also very glad I did not decide to revert to using
TextMate or any of the other new closed source editors.

To conclude, it’s a bit of a feeling-thing. I’d invite you to try it out for a
while to see if it works for or against your flow. No hard feelings either way
:)

PS: It might not be apparent from the article, but the browser provides a few
more functions that os x users might be used to in other apps. See the last
screenshot: <https://github.com/alloy/macvim/wiki/Screenshots>.

~~~
pacemkr
I think I will give this a try. Thank you for writing this and taking the time
to release it.

Browsing codebases that I am not familiar with is the exact use case for me.
For navigating my own project, I do fine with MacVim + Terminal + "mvim in new
tab in existing window conf" [1]. But for exploring an unfamiliar codebase,
it's too cumbersome.

\---[1]---

    
    
      alias mvim="open -a MacVim.app"
      In MacVim Preferences set "Open files from applications" to:
    
        "in the current window"
              "with a tab for each file"
    

Then, in Terminal you can do, "mvim file.ext" to open file.ext in a new tab in
the existing MacVim window (or new if no window).

------
teaneedz
I find myself never straying very far from VIM. It keeps drawing me back. The
registers, motion commands and fingers never having to leave the keyboard just
work so well for me. Multiple tabs in iTerm keep me well organized and speedy.

------
abcd_f
That's a very nicely designed blog. Kudos to whoever did it, Jeff.

------
fictorial
I've personally been thrilled with LustyExplorer

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

------
end550
I'd say most unfavourable opinions are tied to a lack of knowledge but having
powerful features ultimately doesn't negate that it's uncomfortable for some.

------
splicer
gVim is hard; I just want to type ctrl-v to enter blockwise Visual mode.

I normally use vim on the command line, but a lot of my coworkers use gVim on
Windows. Whenever I try to help one of them out, I can't stand the fact that
ctrl-v is remapped to paste by default. I recently found out how to make gVim
sane again. In _vimrc, comment-out the following lines:

    
    
      behave mswin
      source $VIMRUNTIME/mswin.vim

~~~
kaneo
On Windows, ctrl+q will get you the Visual Block selection.

EDIT: I think it also works on Linux... Sitting on my Windows box, at the
moment, so I can't test it.

~~~
splicer
It does (both on Windows and Linux), but gVim still uses v and V for the other
two Visual modes, rather than q and Q. It drives me nuts!

------
igorgue
I'd have probably liked this when I didn't get used to Window navigation on
VIM, now I want everything to work with C-W C-[HJKL].

------
Tharkun
To me the title reads "I just want to dick around", because ultimately, that's
what you're doing.

~~~
desireco42
yeah whole post is kind annoying, he wants to do it, but he will not, maybe he
will, no he will not, like a girl. I didn't find vim that hard at all, just
learn it and use it, that is all.

