
How I boosted my Vim - jkreeftmeijer
http://nvie.com/posts/how-i-boosted-my-vim/
======
there
_Oh, and man… never ever let Vim write a backup file! They did that in the
70’s. Use modern ways for tracking your changes, for God’s sake.

set nobackup set noswapfile_

backup files are one thing, but turning off swap files is a terrible idea. vim
can crash, you can accidentally close the window, your ssh session can die,
etc. if you exit vim cleanly then the swap files will be transparent, so i
don't see the point in disabling them.

~~~
hasenj
so far, swap files have caused me more headache than anything else. I'm a
paranoid maniac and I save every minute or two, so worst case I'll repeat a
minute worth of coding.

What really ends up happening is I try to edit a file and something annoying
pops up telling me about something requiring my attention (swap file already
exists .. read only mode .. bla bla). In other words, it's just a distraction,
most of the time.

~~~
gfodor
Until it saves your ass. Which _will_ happen, if you use vim for a few years.

You can configure it to put your swap files in a canonical dir, instead of
polluting the directory you're editing files in:

set backupdir=/var/tmp,/tmp

set directory=/var/tmp,/tmp

Now you can just nuke the swap files in one swoop:

rm -rf /var/tmp/*.swp

~~~
jamesbritt
Or cron-job the pruning.

------
redraga
Great guide! My .vimrc had most of these settings, but I picked up a few
things that made life much easier. Below are some tricks that I use which
might make useful additions.

Binding the <Esc> key to capslock has been really useful for me.
[http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_XWindow...](http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_XWindows)
explains how you can do this, although it's done externally and not in Vim.
Just include the script in your shell rc file and you're good to go.

Experienced users can hide the menu and tool bars with:

set guioptions-=m "remove menu bar

set guioptions-=T "remove toolbar

Extra screen space for your code is always nice!

Another amazingly useful plugin is MiniBufExplorer
(<http://www.vim.org/scripts/script.php?script_id=159>). This allows you to
open multiple buffers in the same vim window, and with the key binds given in
the plugin page you can switch between buffers just like you switch between
tabs in Firefox. It's really useful when you follow tags in a large source
directory.

And for people who can't seem to find just the right colour scheme: Color
Scheme Pack plugin (<http://www.vim.org/scripts/script.php?script_id=625>). It
has over a 100 different themes, nicely categorized.

------
ptn
One thing that continues to impress me is how much bigger than popular belief
Vim is. There is a plethora of options you can set in your vimrc file (just
now I found out about wildignore, and I'm kind of a Vim addict) and there are
fucking lot of commands (try [I ), and that's not considering Ex mode.

Customization is way easier than in Emacs, you just unzip an archive in your
.vim dir and (99% of the time) it works. I have plugins that do everything
I've seen in Emacs that has to do with code, and then some.

Vim is no more the tiny start-quick-edit-close editor that it used to be.

Edit: I don't want to start a holy war here. Emacs is great, and I in fact
have it opened right now. It's just that it's supposed to be able to do
amazing stuff that Vim can't, I'm saying that that's probably still true, but
to a way lesser level than before.

~~~
ciupicri
Speaking of [I, I prefer Shit-8 (*) or Shit-3 (#).

~~~
sesqu
You seem to have impressed a wrong spelling into muscle memory.

------
amix
In the recent years the booster for me has been the "Command-T" plugin, which
makes it super fast to open files.

I can _highly_ recommend this plugin, even if it's a bit harder to install
than most other Vim plugins.

Check out <https://wincent.com/products/command-t> and
[http://amix.dk/blog/post/19501#Command-T-for-Vim-an-
awesome-...](http://amix.dk/blog/post/19501#Command-T-for-Vim-an-awesome-
plugin)

~~~
nat
I've gotta second this, command-t is probably my single favorite plugin. I
tried using FuzzyFinder way back when, but it was just a little too quirky to
be useful. This blows FuzzyFinder (and even fuzzyfinder_textmate) out of the
water.

Navigating you project in this way feels a lot quicker than actually browsing
the hierarchy with something like NERDTree. Don't worry about where things
actually are, just type some junk and the file you want will almost always
come to the top.

~~~
alinajaf
I used to be a die-hard NERDTree user until I discovered CommandT. It is solid
gold and I couldn't imagine using vim without it.

------
kgroll
This is actually a really good guide. I use vim daily at work, and my .vimrc
shares most of these settings.

One big productivity boost for me was remapping the Escape key to something a
little more convenient. I just remapped the ESC key altogether, but this can
throw you off if you find yourself working at lots of different computers. If
you prefer something less permanent, you can map a key sequence to ESC. I like
this one, which maps 'sdf' to ESC _if you're in insert mode_ :

    
    
      imap sdf <ESC>
    

jkjk is also a sequence I've seen used.

~~~
judofyr
You can also use Ctrl-C to get out of insert mode.

~~~
ptn
Yes, but that's not equivalent to Esc, use this:

inoremap <C-c> <Esc>

------
cageface
I have a similarly hacked up Emacs environment and it's actually gotten to the
point that I'm taking a hard look at IDEs again. Having all this functionality
available in a single integrated package with a visual debugger thrown in is
starting to look strangely appealing.

~~~
edanm
IMO, IDEs are better for almost everything, _except_ for actual text editing.
For that, vim and emacs are still the best (I prefer vim for plain text
editing prowess, but emacs has a lot of other goodies which make it closer to
an IDE, but still not as good).

Obviously, these are only my personal opinions.

~~~
jrockway
I agree that this is true, if you have no desire to learn how Emacs and your
chosen modes work. If you are willing to dig in, the ability to fix your tools
with a simple C-M-x is indispensable, and is a feature that no IDE has.

What features do you think Emacs is missing?

~~~
edanm
Firstly, emacs is not a quick-start environment. If I want to get started in a
new language, let's say Java, downloading Eclipse will make getting started
with Java insanely easy. The same with C++ and Visual Studio. Compare with
emacs, in which I have to spend time getting things to work. I'm not saying
it's worse in the long run (although I suspect you can't beat Java on
Eclipse), but the overhead every time I want to try something new is large.

But the biggest problem with emacs is the "project management" functionality.
Emacs is designed to be "just an editor". To do the most simple thing, which
is to define a project consisting of a few directories, and be able to move
between those files, is very hard. Pick up many modern editors, and you can,
with one command, point to a directory and have a project tree, a "jump to
file", etc, all built for you. Not to mention the way they create makefiles
automatically, do code-completion, create tag files so you can jump to a
function by name, etc.

I can just list the number of things I didn't have to know about before
starting emacs: makefiles, tag files, etc. _Not_ having to worry about these
kinds of things is the biggest feature emacs is lacking.

~~~
jrockway
Makefiles are an acceptable barrier to entry. I've lost a lot of hair trying
to figure out how to build huge Java projects that the developers just built
inside their five-major-versions-old IDE. ("Oh, just build it by clicking the
'export to WAR' button and then copy the file to each production server." No.)

Considering how trivial it is to write an ant file to do the same thing, it's
appalling that the IDEs don't just do this by default. How can you write a
good application if you don't even know how to compile it?

 _But the biggest problem with Emacs is the "project management"
functionality. Pick up many modern editors, and you can, with one command,
point to a directory and have a project tree, a "jump to file", etc, all built
for you._

Emacs does this too: <http://github.com/jrockway/eproject>.

Of course, Emacs' version is a lot more flexible. The user can hook it, so he
gets a fresh project REPL the first time he visits a new project. Or, he can
hook the eproject-after-save hook, and commit the changes to a "backup" git
branch, so that he never has to worry about not being able to undo.

The idea behind Emacs is that it can do things that nobody else has ever done
before, and it continually lives up to this expectation.

(Also, "this is too hard for beginners". OK. Then how did I learn Emacs?)

------
prasanmishra
I am always thinking.. instead of downloading installing plugin here and
there.... can some experienced programmer or vim expert create one full
package which is best for atleast one programming language for e.g., Ruby and
Ruby on Rails. So that newbie can like it. Newbie actually means who spent
months and years on vim but never able to make their primary editor :)

------
graywh
_Another great trick I read in a reddit comment is to use <C-r>\+ to paste
right from the OS paste board. Of course, this only works when running Vim
locally (i.e. not over an SSH connection)._

Actually, it does work over SSH if your X connection is forwarded properly.

~~~
nvie
True, true.

------
swah
I was really expecting to see a link to his git repo in the end.

~~~
adnam
<http://github.com/nvie/vimrc/>

