A Vim Tutorial and Primer
danielmiessler.com
danielmiessler.com
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.
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
It makes sense if your reasoning for using vim is that it is ubiquitous.
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?
C identifiers like AUDCLNT_E_UNSUPPORTED_FORMAT.
(This isn't really relevant to your post, just funny)
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).Also, two high school juniors watching me try this also verified it's coolness.
So not only do you have easy access to keys like "ctrl+d" you also get escape.
In linux, X11, xcape does it.
If you want a more familiar Sublime-esque experience, you can also rebind it from Ctrl-P to Cmd-T (which is how I personally use it).
So my workflow on a Mac is to type `mvim ~/project-dir-goes-here` and then press Cmd-T just like I would in Sublime to start typing in a filename and see a list of matching files to open.
https://github.com/kien/ctrlp.vim http://stackoverflow.com/questions/11979313/command-key-in-m...
If your cursor is on a file name, like "foo.js", you can type gf to "go to that file" for editing.
Going back isn't as easy to remember. It's Control-O. So I map that in my .vimrc to gb like this:
" gf is built in and will "Goto File"
" gb is the opposite, will "Go Back"
nnoremap gb <C-o>If it's C/C++ code I use ctags and cscope and just ":tag <function-name>" to go to the function definition (VIM will autocomplete the function name).
If it's a Rails project, there's a Vim Rails plugin and then ":Econtroller <controller-name>" opens the relevant file, etc.
It's also possible to keep a file listing all of your project files (Or just edit your Makefile if you use one). Then just switch to that buffer, search ("/<blabla>") for the file and "gf" (goto-file - opens the file whose name is under the cursor).
Here's a tutorial[2] for NERD Tree that I quickly found.
[1]: https://github.com/scrooloose/nerdtree
[2]: http://code.tutsplus.com/tutorials/vim-essential-plugin-nerd...
If you want to see a 'file browser', open VIM and type ":sp ."
Strictly speaking you don't need nerdTree (though I love it ).
filetype plugin indent on
syntax on
set encoding=utf-8 set nocompatible- www.vim-adventurs.com. I negotiated an educational discount and rewarded kids points based on the number of levels they completed. A few of the kids actually completed all 14 levels. What teacher assigns game homework? I can say all 16 are using vim on a daily basis for Python with zero complaints. At least to me.
- vimtutor. We spent an hour on this one. It's an app that comes with vi. It really just launches vim with a text file that teaches you the basics.
Yeah, it's $25 but well worth it. You will get stuck. Use his Facebook page for hints.
* 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.
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.
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.
You need to teach prospective vimmers about the native power of vim. The concepts of motions and nouns wayyy before you start finely tuning vim.
A beginner following your guide would be completely lost in a vanilla instance of vim…
Vim users are used to the "modes" like insert, normal, visual. Coming from Vim it feels like Emacs is only in Vim's insert-mode. Having to press ctrl+key just to navigate the screen felt completely wrong to me. All the ctrl/alt keybindings just seems like a recipe for RSI.
However, with the Evil plugin, a Vim user can immediately use Emacs because you're editing with Vim keystrokes. Vim also encourages you to spend as little time in insert-mode, and there are very few commands in Vim that work in insert mode (to be honest, I never use them anyway)
So what you can do is you can tell Evil to drop Vim keybindings when you're in insert-mode (except for ESC) and then.. voila... you're back to Emacs keystrokes, but only while you're in insert-mode (which is what Emacs seems to be about anyway)
;; use Emacs keybindings when in insert mode }:)
(setcdr evil-insert-state-map nil)
(define-key evil-insert-state-map [escape] 'evil-normal-state)
This is the coolest thing ever if you want to learn both editor's commands, or if you're coming from the one/going to the other. (Yeah you can switch mode with Ctrl-z but this is "seamless" for a Vim user)You probably also want the Evil-leader plugin so you can map things like ",f" to find-file and ",h" for help-command, etc.
ido-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.
Simp.el, that act like sublime text fuzzyfinder : 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....
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.
Play with them and see if they can be useful to you ;).
One favorite tweak of mine for file finders like this in general: rewrite the dir listing to use "git ls-files -co --exclude-standard". This obviously only works in git projects (similar commands exist for mercurial I think), but is really fast and most of the time is exactly what I want.
My guess would be that if the features you want are available, they might not be packaged in the same way, so listing some key features might get you more answers.
this did not add a colon to the entire file for me.
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.