
Getting started with vim - grey-area
http://lucapette.me/getting-started-with-vim
======
MichaelGG
Vim keybindings are amazing. Easiest way to think of it is to think of how
frustrating it is watching someone do everything with a mouse, not knowing any
shortcuts. Clicking File -> Exit instead of the window's X. Or deleting a
whole line of text just to change one word. Not knowing Ctrl-X/C/V.

That's how I feel when I work with someone editing text files without Vim.

Once again I'll recommend Vim Adventures[1]. It's fun enough even my 8-yr-old
daughter wanted to play/learn. You learn a few keys at a time; no big deal.
Meanwhile, install Vim emulation in your current text editor. Slowly you'll
learn keys. Your desire for knowledge will increase, and you'll start picking
up the ideas mentioned in the article. Within a few months you'll be flying
and wonder how you ever coded without it.

The key is making it a natural thing, not forcing yourself to "learn Vim". At
least for me, those approaches failed due to the short-term productivity
decrease.

1: [https://vim-adventures.com/](https://vim-adventures.com/)

~~~
crowbahr
My 1 gripe with vim adventures is the whole subscription based model for a
game. I went ahead and shelled out for the full thing but after 6 months I was
no longer allowed access because my subscription had expired. That's some
bullshit.

~~~
pmoriarty
Don't you miss the days when you could just buy software once for a reasonable
price and own it forever?

~~~
crowbahr
Even though my development role means I do SAAS yes, yes I do miss owning
software forever.

------
exDM69
My advice: don't go wild with plugins or vimrc hacks. Get sensible.vim for
sensible defaults and work with that. Vanilla vim is good enough for most
editing and coding needs.

~~~
JupiterMoon
My retort. Install YouCompleteMe because if you don't have high quality auto-
complete your editor will feel rubbish compared to an IDE and you will end up
moving.

~~~
RandomInteger4
Is autocomplete really necessary though?

~~~
jasonkostempski
Do you have any suggestions about how it may not be, or are you just pondering
the idea? I really want there to be something that has the benefits without
the Intellisense-level overhead, I haven't seen it though.

~~~
Normal_gaussian
I find autocomplete annoying.

I also suspect autocomplete to be the leading cause of a particular set of
subtle bugs - ones where the words on the page seem right but the function
chosen has a surprising and uncatered for side affect.

When you reinforce to people that it is OK to code blindly ahead, grasping for
the right calls at the last second you will end up with poorer quality code
(although, it may be typed faster).

~~~
yomly
There are always tradeoffs but for me, I feel like lack of autocomplete
encourages people to use shorter less descriptive names for identifiers.

I am a believer in using as descriptive identifiers as possible to make the
semantics of your code as clear as possible. If this gives rise to 5-word+
identifiers, so be it, providing it is done tastefully (and not for
verbosity's sake).

As typing 10+ characters per function call/variable call can get tiring, lack
of autocomplete can leads incentivizes the use of shorter names which runs
counter to this philosophy, and leads to code being harder to read. (IMHO)

------
vertex-four
If vim doesn't click for you, I'd really suggest trying kakoune. It swaps
vim's behaviour around - where vim commands are "verb-object", kakoune's
default behaviour is to allow you to select things, and perform an action on
them once you know what you're operating on. Movement is precisely equivalent
to selection - w is "select the next word", W is "expand the selection across
the next word".

The visual feedback makes it easier to pick up (for me), and also makes
building up complicated sequences of actions very easy. Multi-selection ties
into that as well - a common workflow for me when editing is to select an
object (a-a or a-i), split it by some regex into multiple selections (s), then
perform my changes on those selections.

~~~
majewsky
I saw Kakoune last week on HN and think about giving it a shot. Can you
comment on how extensible it is? Are there extensions available, and can I
write my own?

~~~
vertex-four
I've not played much with extending it past writing a couple of hooks. It has
a decent enough hook system. What would you like to try and replicate in it?

------
sayelt
At work nobody understands why I use Vim, I'm tired of having to explain
myself to my coworkers and hearing all the time "Why don't you just switch to
Atom?"

~~~
threatofrain
I have trouble understanding Vim as well. It seems to be good at code editing,
where I find that I'm not bottlenecked there. I'm bottlenecked at my ability
to plan and think about programs.

Once I have either a plan or comprehension of a program, I move at lightspeed,
and typing becomes a small proportion of software production time. When
editing an unknown codebase, it becomes even more imperative to have
comprehension + plan before making an edit.

Also, since its my ability to comprehend and plan that is so strained, I'm not
sympathetic to Vim's lack of anything like intellisense, or cross-file grammar
and type awareness + autocomplete.

~~~
2muchcoffeeman
Exactly why I use vim bindings in Intellj.

Typing may be a small part, but there's no reason not to make that part
efficient.

------
chestervonwinch
I like this quote:

> Vim is a small language for editing text that ships with a small user
> interface.

Pardon my ignorance, but are the two separable? Could someone write a GUI
interface that uses the vim text editing language underneath? I know of gvim,
but this seems to be just vim with a menu bar.

~~~
mrkgnao
There are plenty of Vim emulator plugins for "GUI editors" like Atom (or even
the Visual Studio family, as a comment in this thread mentions) that do just
that!

~~~
chestervonwinch
Yes, I've used them in emacs, atom, etc. They're useful, but often feel
unnatural. I was looking for something that was built from the ground up
specifically as "vim editing with a nice interface" \-- maybe this is neovim,
as someone else suggested.

~~~
johnchristopher
Nope, VIM the UX (keys and movement) and VIM the application are not separated
at the moment.

It would be great to be able to use VIM key movement as drop-in replacement
for any text field OS wide but the VIM interface (the command line) plays an
important role in the UI and I don't see how it could be swept aside without
losing some VIM core functionality: EG how do you :%s///gi without the overlay
command line ?

~~~
majewsky
I actually have a design document from 5 years ago lying around in my backup
that outlines a desktop shell based on (and expanding on) vim's UX. I should
get back to that project one day.

------
sharmi
Shortcut Foo's vim dojos are also a good way to learn all the shortcuts in vim
once you have got the basics down (opening and closing files, insert mode etc)

Each dojo trains you on a few related set of vim actions.

Practice one dojo at a time and try to use it during your regular editing.
Once you have incorporated it into your existing workflow, move to the next
dojo.

[https://www.shortcutfoo.com/app/dojos/vim](https://www.shortcutfoo.com/app/dojos/vim)

------
atsaloli
I'm looking forward to teaching a Vim class in Seattle next month.
[https://www.casitconf.org/casitconf17/tutorials/](https://www.casitconf.org/casitconf17/tutorials/)

I've got some resources for learning Vim on
[http://www.verticalsysadmin.com/vi.htm](http://www.verticalsysadmin.com/vi.htm)

------
maxboisvert
For an easy start, use a sane defaults plugin like sensible.vim [1] or vim-
simple-defaults [2] (more opiniated).

Also, use vim-plug [3] with few plugin like ctrlp, nerdtree, nerdcommenter and
vim-simple-complete [4].)

[1] [https://github.com/tpope/vim-sensible](https://github.com/tpope/vim-
sensible)

[2] [https://github.com/maxboisvert/vim-simple-
defaults](https://github.com/maxboisvert/vim-simple-defaults)

[3] [https://github.com/junegunn/vim-plug](https://github.com/junegunn/vim-
plug)

[4] [https://github.com/maxboisvert/vim-simple-
complete](https://github.com/maxboisvert/vim-simple-complete)

I am the author of [2] and [4].

------
jimnotgym
For someone mostly playing with Python, and using Atom, what is the great step
forward that editors like Vim and Emacs offer?

I read things like this occasionally and still don't really get _why_? Why is
the learning curve worth it?

~~~
beachstartup
speed and efficiency.

some people don't care about those things, some people do.

~~~
jimnotgym
Exactly the kind of thing I have read. But nothing explaining _how_ it
achieves that

So it has keyboard shortcuts, and I guess I could add those to another
editor...

Is it one of those things you just have to take someones word for it, have a
go with it and see?

~~~
beachstartup
in your editor, without leaving the keyboard, how would you search-and-replace
using a 2-variable regex, only between lines 275 and 1305, and then turn every
instance of 'TEST_' into a lowercase, but only on the lines that didn't match?

~~~
pyoung
How often do you find yourself doing operations like this? I feel like it
would take me more time to formulate and confirm that your set of commands are
correct than it would for me to just ctrl+f to each instance and then ctrl-v
the ones that needed to be changed. Don't get me wrong, I think it is really
cool that you can do this, but it feels like this requires a level of fu that
is beyond most typical programmers.

~~~
beachstartup
you search and replace by hand?

... are you serious?

~~~
pyoung
Thanks for the substantive reply;)

In almost all cases where I need to do a find/replace there are typically no
more than 4-5 references that need to be updated. And I think a better way to
phrase my behavior is I search, inspect the code to make sure that my change
won't introduce a bug or some unintended consequence, and then replace. This
may be slower, but in the grand scheme of things it barely registers on my
overall productivity and if it saves even one bug from getting introduced into
the code than the extra time spent probably pays for itself. If I need to
update more than just a handful of references, than Sublime has a perfectly
functional find/replace tool, but I have only ever really needed it maybe 3-4
times in the last few years.

To get back to the question at hand. How long does it take you to formulate
these series of commands in your example? Because to me it feels like it would
take longer to come up with a correct set of commands for your example than it
would be to just search and replace 'by hand'. Of course if you are updating
100's of references than spending some extra time to formulate your solution
makes sense, but in your example, you limited your search ~1000 loc, so
presumably you are only updating a few lines, maybe a dozen at most? I
understand that vim is powerful tool, but it seems to solve problems that I
don't have (or that I don't consider to be problems), and I am genuinely
curious as to the sort of problems and types of code bases that vim
aficionados work on.

------
whatupmd
Thank you for writing this great summary. Just last week I was was trying to
compile such a list as a 'novice' user and this has everything I had
bookmarked and much more.

My focus was on portability, I switch systems alot, I don't know how practical
carrying all these plugins around is but have not given vundle a try yet.

I have to say that working with VIM feels like a weekly/monthly epiphany's. I
will discover something new that can be incorporated into my workflow and
can't believe what I'd been missing all along.

------
melling
Modal keybindings seem to be the most efficient way to work in an editor.

Xah Lee created one for emacs. Has anyone given it a try?

[http://ergoemacs.org/misc/ergoemacs_vi_mode.html](http://ergoemacs.org/misc/ergoemacs_vi_mode.html)

[https://github.com/xahlee/xah-fly-keys](https://github.com/xahlee/xah-fly-
keys)

~~~
mrkgnao
Isn't evil-mode more well-known?

~~~
melling
Sure, that's vi bindings. The author analyzed his layout and claims this is
more efficient.

------
joncp
If you're in the Visual Studio ecosystem, I enthusiasically recommend ViEmu.
It let's you learn the vi keystrokes a little bit at a time, all the while
being able to fall back to the VS keys when you don't know how to do something
the vim way. It really flattens out the learning curve tremendously.

------
maouida
I started to used VIM seriously last month. My biggest concern so far is
editing new files. Too much switching between INSERT and NORMAL modes.

This is not a problem when editing existing files.

Also I think some keyboard shortcuts are not comfortable on an AZERTY keyboard
layout.

~~~
d0vs
Have you remapped Caps lock to Escape yet?

~~~
u801e
I just use ctrl-[ to go back to normal mode. I actually do use the CAPS LOCK
key for typing in all caps on occasion, so I would rather not remap it.

------
danidiaz
Vim itself comes with a user manual, besides the command reference. :h user-
manual

Another site with good general advice is [https://www.vi-
improved.org/](https://www.vi-improved.org/)

