
A Vim Tutorial and Primer - danielrm26
http://www.danielmiessler.com/study/vim
======
raimue
So, the first motivation for using vim is that you think it's readily
available everywhere. However, the first thing you explain to me is how to
remap the Esc key. That is definitely not something configured everywhere.

For beginners with vim, just leave the Esc key as it is. It is way simpler to
grasp the modes if a single key is required to switch. Also, you can just
hammer a single key multiple times to get back to normal mode at all times.

Mapping keys are an advanced topic. That is not the first thing you should
start with when explaining vim. Unexperienced users will not understand the
significance.

~~~
Crito
> _" So, the first motivation for using vim is that you think it's readily
> available everywhere. [...] That is definitely not something configured
> everywhere."_

The aversion to custom settings is a rather uniquely "vim thing" (emacs people
don't seem to do it), but I've never understood why it is a thing. I am
probably temporarily annoyed by my missing custom settings once every year or
two _at most_.

Most machines I work with get my vim config lazily loaded as I use them. Where
that isn't feasible/possible/permitted, the lack of my custom color scheme
flips a bit in my brain and I naturally use the compat feature set.

Custom settings not being ubiquitous is an objection that makes sense in
theory, but it just doesn't seem to be an issue in reality to me. Honestly I
have more trouble with ~/bin

~~~
pessimizer
>Custom settings not being ubiquitous is an objection that makes sense in
theory

It makes sense if your reasoning for using vim is that it is ubiquitous.

~~~
Crito
Right, but even if that is your reasoning, the objection does not hold if you
observe reality. In reality, even ubiquity is a reason you use vim, custom
settings aren't damaging.

------
sstanfie
Some thoughts on CAPSLOCK remapping:

After using vi / vim since 1986, I finally remapped CAPSLOCK to CTRL at the
operating system level. It's made a world of difference, and not just for vi.
It easily unlocks all the EMACS style cursor movements like ctrl+A, ctrl+E,
etc.

Yeah, I know you can do it with the CTRL key in the lower left. But if you
move from Mac laptop with Fn key in lower left, to an external keyboard with
no Fn, you're gonna have a bad time.

But here's another reason why I advocate this approach. Remember vi was
written by Bill Joy back in the 1970s. Back then, the early terminals had the
control key right there next to the A. In fact, the CAPSLOCK was to the left
of that!

I was recently at the Computer History Museum in Mountain View where you can
see some of these early terminals. A lot of us know the Happy Hacker Keyboard,
with the control key at it's rightful place. But to see it on the old
terminals, it's a pretty good archeological insight into why it just feels
right.

Plus, WHO USES THE CAPS LOCK KEY ANYWAY EXCEPT FOR SHOUTING IN FORUMS?

~~~
coldpie
> Plus, WHO USES THE CAPS LOCK KEY ANYWAY EXCEPT FOR SHOUTING IN FORUMS?

C identifiers like AUDCLNT_E_UNSUPPORTED_FORMAT.

~~~
irahul

        inoremap <C-x>c <esc>bgUWea
    

Type the identifier in lower case, and then <C-x>c(or whatever you feel like
mapping it to).

~~~
sstanfie
OMG that is so cool. I just added it to my .vimrc.

Also, two high school juniors watching me try this also verified it's
coolness.

------
imslavko
For me a big discovery in Vim after two years of active use were <C-i> and
<C-o> in normal mode. They allow you to jump between your navigation history.
Allows you to edit a piece of code. Search for something else in the same
buffer and go back in one stroke. Useful if you lookup documentation or often
"jump to definition". Works across files so you can "git grep", iterate
through the result list and go back to your editing position.

~~~
danielrm26
I'll add this. Thanks!

------
janus
As always, what loses me on vim is that I'm not sure what's the
easiest/best/common way to have a "project directory" open and quickly open
one of the files inside that directory... no basic tutorial seems to tackle
this, yet it's essential to migrate from any other editor you use as a
programmer...

~~~
cal2
I'm not sure if this is what you want, but NERD Tree[1] works for a lot of
people.

Here's a tutorial[2] for NERD Tree that I quickly found.

[1]:
[https://github.com/scrooloose/nerdtree](https://github.com/scrooloose/nerdtree)

[2]: [http://code.tutsplus.com/tutorials/vim-essential-plugin-
nerd...](http://code.tutsplus.com/tutorials/vim-essential-plugin-nerdtree--
net-19692)

~~~
janus
thanks, I'll give it a try. When I briefly tried NERDtree, my issue was how to
switch back and forth between the tree and the opened files list

~~~
bitcrusher
hold down control and hit w, twice, when in visual mode. That will move the
cursor from frame to frame.

If you want to see a 'file browser', open VIM and type ":sp ."

Strictly speaking you don't need nerdTree (though I love it ).

------
seanccox
Perhaps beginners aren't in the intended audience, but as a cautious (Level 0)
beginner to Vim, you lost me at the "Configuration" section. I appreciate your
impulse to teach and I like the layout of the guide, so I hope you can massage
it a little for a beginner like myself.

~~~
danielrm26
My apologies. Can you tell me what tripped you up and what you would have
liked to have seen?

~~~
oinksoft
I'm not your audience at all, but a few ideas from that section:

* You refer to ~/.vimrc and ~/.vim with no prior introduction. Even assuming knowledge of "~" expansion is risky, and ignores Windows users.

* You mention a "self-managed Vim install" and Janus in passing. Who cares? It's confusing.

* Why am I remapping stuff I haven't used yet (<Leader>)?

* Why am I remapping <Esc> to `jk` (why would you suggest such a radical change for somebody just starting out?)

* Why do I care about CAPSLOCK?

* Pathogen? Github? What's going on? I thought I was learning an editor.

This is kind of a scatter-shot ... there's a lot of stuff that makes no sense
unless you're already familiar with Vim, and with configurable Unix text
editors' mode of operation in general.

~~~
seanccox
What oinksoft said.

I think it's a common mistake of people who want to teach anything, but I see
it frequently in coding (probably because that is what I am trying to learn
these days). That problem is usually articulate with this phrase: "Before you
get started..."

Essentially, when I look for a beginner's guide, I want to start at the
beginning. There is nothing before the beginning. If I need to plug something
in, turn something on, or install something, I'd like to know how to do that.
I exaggerate only slightly. For example, when I was learning to play the piano
as a child, I started centered on the first note I played, which was a G, and
arranged myself accordingly to accommodate my chosen midpoint, since no one
had taught me about Middle C.

Oinksoft's points are all crucial. You're clearly knowledgeable, but those
details are beyond the scope of my understanding for a Level 0 beginner, so if
they are essential, they need to be broken down. If they aren't, then you can
leave them out.

As a general rule for teaching anything, you should explain, demonstrate, and
then solicit a student response or reproduction of the concept. I think the
material you have here can be arranged such that it accomplishes these
components, and rearranging it thus would make it easier for someone ignorant
of the subject, like myself, to follow along.

I hope this is helpful criticism. I really like what you're doing and I'm
excited by your attitude – 'basics to ninja' – because this is useful for
preventing learners from stagnating. With some work on the beginner level
information, I think you'll have a solid guide.

~~~
seanccox
Here's a decent example of the ideal approach to laying out the material:
[https://wiki.python.org/moin/BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide)

It could be better if I didn't have to follow links to other parts of the site
in order to complete the initial tasks. Creates a lot of back-and-forth in the
browser, and there will already be a great deal of that as I attempt to switch
window to install, open a text editor, etc. However, the outline captures the
suggestions I was trying to make above.

------
Blinkky
The Advanced section should definitely talk about marks.
[http://vim.wikia.com/wiki/Using_marks](http://vim.wikia.com/wiki/Using_marks)

~~~
danielrm26
This is the author, and you're absolutely correct. I'm going to add it soon.
Thanks!

------
plg
Is there anything like org-mode (emacs) with vim?

~~~
jbeja
Why don't you try Emacs with Evil-mode (all the power of emacs with vim key-
bindings). I have made change an never look back.

~~~
MetaCosm
Do you happen to know of a cross-platform fuzzy finder for emacs? Bonus points
if it can also fuzzy-find over tags.

~~~
jbeja
There is:

ido-flex: [https://github.com/vic/ido-better-flex](https://github.com/vic/ido-
better-flex).

ido-verical mode (just to make ido to display results in a column instead a
row): [https://github.com/gempesaw/ido-vertical-
mode.el](https://github.com/gempesaw/ido-vertical-mode.el).

Simp.el, that act like sublime text fuzzyfinder :
[https://github.com/re5et/simp.Also](https://github.com/re5et/simp.Also) is
good to read this post about it: [http://ck.kennt-wayne.de/2012/aug/find-
project-file-with-fuz...](http://ck.kennt-wayne.de/2012/aug/find-project-file-
with-fuzzy-matching-in-emacs).

And this new one called "ag.el" that is "An Emacs frontend to ag, ("the silver
searcher" ack replacment)":
[https://github.com/Wilfred/ag.el](https://github.com/Wilfred/ag.el).

Play with them and see if they can be useful to you ;).

------
jordanlev
I run Chrome with cookies (and local storage) disabled by default. When I
visit the site, I only see the first two headings of a table of contents, and
no actual tutorial content appears. Why does an information-only (non-
interactive) web page require cookies and/or local storage to function?

------
williadc
Great tutorial. There's a mistake in "Getting things done" -> Moving within
the Screen. It lists ^U and ^D as moving a full screen, which is not true.
Those only move half a screen. You correct this a few line later... I think
you just forgot to take it out.

~~~
danielrm26
Fixed, thanks!

------
erikb
What is "cit"? It doesn't explain it. "t" is only presented as a verb but not
as an object as far as I can see.

~~~
redwall_hp
Change Inner Tag. You could also use ci" to change inside quotation marks, or
yit to yank the text, etc.

------
platz
0i:j0vG.

this did not add a colon to the entire file for me.

~~~
coldpie
The guide is a little off in parts, and that was one of the worst offenders.
It assumes you're on the first line. Then, you have to hit Escape after typing
the colon. Finally, the whole command depends on your having "vnoremap .
:norm.<CR>" in your configuration, which I sure don't.

~~~
bstpierre
Thanks for that tip! I wandered in here hoping someone had already asked and
answered and got my reward.

I mostly use emacs for the past 15 years, but I learned vi about 20 years ago
and use it regularly at something approximating level 4, but only for vi (not
vim) commands -- having no real knowledge of visual mode or some of the
extended commands. One of the hard things about learning vim is figuring out
how to search for help -- because "enable dot command in visual mode" (and
variants) doesn't turn up anything useful right away. I know I've got the
right idea (esp. when seen in a tutorial like this one) but there's some
setting or plugin or subtle nuance that I'm missing.

------
brenfrow
FYI: Clicking on "Working With Your File" isn't linked correctly.

