Use Vim Like A Pro
tottinge.blogsome.com
tottinge.blogsome.com
1 See spelling in use at http://www.vim.org/about.php
2 "Vim has a small footprint in RAM and on the CPU. A given system can support a great many VIM users at once."
I was used to editing files over ssh with Vi, but after they improved;) I was hooked on Vim forever. Vim really is an absolute a must-have skill in your toolbox.
Not to diminish on the author's efforts. The tutorial he wrote taught me about vim's capabilities in directory mode — I would usually just quit every time I accidentally ended up in it.
inoremap <C-s> <ESC>
vnoremap <C-s> <ESC>Personally, I remapped caps lock to esc, because I don't like the way the editor lags when typing an "i" after "ii" has been remapped, but Caps-->Ctrl has the additional benefit of making other Ctrl-Foo sequences easy.
> Personally, I remapped caps lock to esc, because I don't like the
> way the editor lags when typing an "i" after "ii"
That's the problem with mapping non-Ctrl/Alt sequences in Insert mode. Even thing like bindings that automatically insert a closing } (with auto-indent) when you type the opening { are really annoying because they are commonly bound to the sequence "{<Enter>". So when you type { without <Enter> there is a delay while it waits to see if you're going to hit <Enter>.asc<C-v>i<C-v>i
in insert mode.
Also, the happy haacking keyboard already puts control in its proper place and puts esc where ~ normally is, which is close enough that you don't really need to remap it. Best vim keyboard ever.
Insert mode is not Vim's 'normal' mode. When you enter Insert Mode, you are basically saying, "I'm stepping out of normal mode for a bit to enter some text here." In this sense, hitting ctrl-c is telling Vim that you're aborting your insert operation. (Though I could just be talking out of my ass, and it was just bound that way as a convenience)
Unicomp makes a Model M that does this as well, very worthwhile if you are a vim or Emacs user: http://pckeyboards.stores.yahoo.net/linux101.html
Yep, that's good 'ol vim for you.
http://news.ycombinator.com/item?id=1687701
I did the same thing, based on that post.
Edit: er, maybe not that one, can't find it in the page. Could have sworn that was it though...
That's where I picked it up, too :-)
Incidentally I also remap jh to write & exit insert mode (inoremap jh <ESC>:w<cr>). This turns out to be super helpful for web development, which often requires that you hop over to a browser after modifying code.
:au FocusLost * :wa
should autosave when you switch to the browser without requiring keypresses.It's like a puppet master wiring her fingers to fully express herself through the puppet. In the case of programming, Vim is the wire and the puppet is the code.
I caught Drew's talk at Arrrrcamp on Friday and he is a fantastic explicator. His Vim book for PragProg should be excellent.
It's an amazing plugin that brings Vim-like keyboard mappings to the browser, making it significantly easier to build muscle memory.
Only a few keybindings, but I only really use it for the j/k page navigation.
(Note: it does get overwritten by pages with their own keyboard navigation (flickr, tumblr's dashboard, ffffound, etc.))
This fellow puts up bite-sized, five minute screencasts of various Vim-related features. Some of the 'casts are more advanced, and some of them are pretty basic.
The padding between the left edge of the window (or the right edge of the line numbers) and the interior text it ~0. I'd like just a little padding.
anyone?
:help numberwidthI do not know if it's possible to do what you want. I find that a slight variation in background color (:highlight LineNr) helps in distinguishing the numbers from the content.
I posted to superuser with an image to give you an idea of what I'm talking about:
http://superuser.com/questions/205553/how-can-i-add-some-pad...
Example: http://tinypic.com/r/f0u84/7
:set foldcolumn=3 (or 4 or 5 or what4ever. . . )
:hi FoldColumn guifg=black guibg=black
That should do it.
Is there a way to swap the foldcolumn to the left of line numbers?
Doesn't look like anyone's posted this link as yet.
The NERD Tree plugin gives you a directory tree that lets you easily move between files and do filesystem operations.
Vim certainly has a lot of ninja editing moves (however, I don't think my development speed is particularly limited by my raw text editing speed).
Vim is a great editor, it just lacks a decent implementation; GNU Emacs is a great OS, it just lacks a great editor. GNU Emacs + Viper + Vimpulse is what you should learn and use for maximum effectiveness.
This one brought ^T and ^D for indenting in insert mode to me, and starting with -o/O as argument for opening multiple files in splits.
A simple http://github.com/search?&q=vimrc is a goldmine for mastery.
Do it on a line where there is a pair of quotes, parens, brackets, etc.
* `less +23 file.txt` opens the file in less at line 23
* Searching in less works just like vim:
/ -- starts a forward search
? -- starts a backward search
n -- cycle through matches forward
N -- cycle through matches backwards
* Some movement keys are shared:
gg -- go to the top of the file
G -- to go the bottom of the file
... etc ..."Yank from the current character to the end of the line into register y"
should be:
"yy$
instead of
"y$
/symbol
Oh, it's a metacharacter? /\meta
\ escapes metacharactersIt's in the docs. Essential.
http://www.emacswiki.org/emacs/EmacsCrashCourse is fairly good for a quick introduction to similar ways of doing things in emacs. =)
The first thing a new Emacs user should do is to peruse the Emacs manual. You won't remember every detail, of course, but you should at least have a basic idea of what sorts of operations are available.
Then, start editing text. When you do something that seems tedious, you're doing it wrong. Try to remember back to the section of the manual that has something to do with what you were doing. Then read that section. Now try to redo the operation, but "the Emacs way" instead of the tedious way you invented yourself.
Do this several times a day.
Now you're an expert.