
Vim After 11 Years - statico
http://statico.github.com/vim.html
======
h2s
Lots of people seem to declare ; or , to be useless keys and remap them.
They're two of my most used movement keys in certain circumstances.

I used to have , remapped to <leader> but switched back when I realised what I
was missing out on. I'd advise anybody else to reconsider if they've made the
same mistake I did.

~~~
danneu
I've had ; mapped to : forever.

Is there a use for `;` I'm missing out on? `;` just seems to be for stuff like
"`fp` -- Oh wait, I didn't see all the p's between my cursor and the p I
wanted. ; ; ; ;."

Now I use easymotion.vim which obviates that scenario.

~~~
goldfeld
I created vim-seek exactly for this reason, it's like f but takes always two
characters, way faster than easymotion within the line (though I still use
easymotion for longer distances) <http://github.com/goldfeld/vim-seek>

~~~
danneu
Cool! Until I found easymotion.vim, I was sort of doing a poor man's vim-seek
with `/` and two chars.

------
niggler
PG is there a way to have HN present the subdomain for github submissions?

~~~
julian37
I'm using <http://userscripts.org/scripts/review/121512>, works very well.

~~~
niggler
Doesn't work in chrome :/

"Apps, extensions, and user scripts cannot be added from this website"

~~~
roryokane
You can make it work in Chrome; there’s a way around the warning. Instructions
are in “Steps on adding extensions from other websites” on the Chrome help
page linked from that warning:
[http://support.google.com/chrome_webstore/bin/answer.py?hl=e...](http://support.google.com/chrome_webstore/bin/answer.py?hl=en&answer=2664769&p=crx_warning).
In short, to add the user script, open Tools > Extensions, then drag and drop
your downloaded 121512.user.js file into the Extensions tab.

------
gfodor
Some small vim tweaks I've recently been using myself that I find very nice:

nmap <CR> :write<CR>

cabbrev w nope

Re-map enter to save the file. If you try to do a :w it will yell at you until
you take out the cabbrev so you can retrain your muscle memory. Took me about
a day to retrain.

let g:EasyMotion_leader_key = ';'

nmap s ;w

nmap S ;b

Remap s and S to be easymotion forward and backward. I never use s, since it's
largely a redundant command, and didn't like having to do a two key command
for easymotion. (You can set the leader key to whatever here, the nmap's are
the important part.)

noremap <C-H> <C-W>h

noremap <C-L> <C-W>l

noremap <C-J> <C-W>j

noremap <C-K> <C-W>k

Move between panes with motion keys with control held down.

Also the YouCompleteMe plugin got some HN airtime but it really needs to get
more. It's amazing.

<http://valloric.github.com/YouCompleteMe/>

And as others have mentioned using vim inside of tmux is very nice. It's
especially helpful to remap the entire tmux keymap to be vim-like.

Also, does anyone have any suggestions for what to re-map Space to? I am
amazed Enter and Space in command mode both do relatively useless things.
Remapping space to page down is OK but I use ctrl-f/b which is just as fast
imho.

~~~
ckw
Space is my leader key.

~~~
straws
Same, and return is my BufExplorer. Lightning fast.

------
puls
Why do people keep suggesting iTerm2? The built-in terminal app on the Mac
does Unicode and 256 colors just fine.

~~~
Xion
iTerm2 has few other fancy features, like horizontal and vertical splitting or
Guake-like top-down terminal [0].

[0] [http://ivanvillareal.com/osx/setup-iterm2-to-behave-like-
gua...](http://ivanvillareal.com/osx/setup-iterm2-to-behave-like-guake/)

~~~
niggler
I've used visor/simbl in leopard and snow leopard for years to get the top-
down effect in terminal: <http://visor.binaryage.com/>

------
enoch_r
I recently switched to Vundle from Pathogen and it is a joy to use. Best part:
you can bootstrap[1] Vundle from your .vimrc, turning the two-part "vimrc &
plugins" configuration into a one-part "vimrc" configuration.

<https://github.com/gmarik/vundle/blob/master/test/vimrc>

~~~
johncoltrane
No you can't, you still need to have vundle installed.

~~~
enoch_r
Nope, I've done it quite a few times--you can bootstrap it from your vimrc
like so:

    
    
      if !isdirectory(expand(root, 1).'/vundle')
        exec '!git clone '.src.' '.shellescape(root, 1).'/vundle'
      endif

~~~
johncoltrane
Thanks.

------
zokier
I'm not sure why the author advocates job control (ie ctrl-z/fg/bg) instead of
using tmux/screen. A multiplexer offers far more flexibility, and most
importantly does not lose state even if your session ends (eg ssh connection
drops).

~~~
pekk
While that's true, clipboard interaction through tmux is awful.

~~~
saurabh
[http://grota.github.com/blog/2012/05/08/tmux-clipboard-
integ...](http://grota.github.com/blog/2012/05/08/tmux-clipboard-integration/)

------
jrogers65
> Emacs has a useful mode which highlights hexidecimal colors in CSS and SASS
> with the color represented by the text.

<http://www.vim.org/scripts/script.php?script_id=2937>

> The biggest hole, however, is the lack of refactoring and smart completion.

<http://eclim.org/>

~~~
pekk
For Python, there is a choice of the jedi library or the rope library to do
refactoring and smart completion. This in addition to ctags and the like. I
imagine other languages have similar things.

~~~
luckystarr
Jedi is pretty good actually. Initially it would sometimes be slow and mess up
buffers, but that didn't happen for a long time.

------
SeoxyS
My single greatest tip to make vim even more amazing is to run it in a tmux
session: It makes it super easy to split panes and create new windows for
related things you need to do (git stuff, compilation, running tests, running
a REPL, etc.)

~~~
gnosis
You can easily split panes (called windows in vim) within vim. You can also
create new tabs within vim for related things you need to do.

I still use tmux or screen to do other things which aren't convenient or
elegant to do within vim, but splitting windows and creating tabs can be done
just fine within vim itself (or, in my case, within gvim, which I prefer due
to the increased color gamut and keybinding abilities over terminal vim).

~~~
SeoxyS
When I said split panes in tmux, I meant to put shells, repls, or servers. I
also use split panes and tabs within vim for extra buffers.

~~~
q_revert
you should take a look at <https://github.com/jpalardy/vim-slime> , very handy
for sending code from vim sessions to other tmux panes

------
derwiki
The author mentioned CtrlP for fuzzy filename matching. Its great because it's
in pure Vimscript, but in my experience it becomes unusably slow for
moderately sized projects. A month or two ago, I switched back to CommandT
(requires Vim to be compiled with Ruby support, engine written in C) and
haven't thought twice about it since then.

~~~
pieceofpeace
I have a repo with 3000+ files and I can't notice any delay searching with
CtrlP. I have the following custom file listing command in my vimrc:

    
    
        let g:ctrlp_user_command = {
          \ 'types': {
            \ 1: ['.git/', 'cd %s && git ls-files'],
            \ 2: ['.hg/', 'hg --cwd %s locate -I .'],
            \ },
          \ 'fallback': 'find %s -type f'
          \ }

~~~
atjoslin
Just made my CtrlP use ag[1], it's awesome now :-)

let g:ctrlp_user_command = 'ag --nogroup --nobreak --noheading --nocolor -g ""
%s '

[1] <https://github.com/ggreer/the_silver_searcher>

------
brown9-2
_One of Vim’s strengths is that it starts lightning fast, so starting Vim from
the terminal is trivial. With a modern, 256-color terminal like iTerm2 or
Gnome Terminal, it will even look like gVim. But the best part is that you can
drop into the command line at any time with Ctrl-Z, which suspends Vim, and
your working directory is where you left off._

Is there any reason to do this instead of _!sh_ within Vim to drop into a
shell?

~~~
slurgfest
have your terminal map Ctrl-Z to fg, and you can cycle in and out of the shell
almost instantly from vim with that key.

~~~
bsg75
As in Ctrl-z to background, and Ctrl-Z to fg back into vim from the shell?

~~~
danneu
I'm sure they mean `map fg <c-z>` in Vim so that `fg` from Vim lines up with
`fg` from shell and you can repeat the same stroke to easily "toggle" Vim.

------
yaj
I can live without Vim but cannot without Vim mode.

All apps I have used since learning Vim has some kind of Vim bindings - Visual
Studio, Eclipse, PyCharm and ST2. I also rely on browser vim plugins (vimium,
vimperator).

It seems Vim mode is becoming ubiquitous in my apps.

------
Aardwolf
Can vim do the following?

I'm editing some project with 10000 C++ files.

There is some C++ file I currently don't have open, say "palette.cpp" which is
in a subdirectory "project/graphics/algorithms/color/".

Now I want to open palette.cpp without ever having to type, not even with tab
autocompletion, that path.

IntelliJ (which I do use for C++ ;)) can do this easily: just press CTRL+R,
then palette.cpp, ENTER, and there you are in that file.

Another thing: Some IDE's and editors have this feature where if you change
lines, it marks it with some color on the left, as well as colors in the
scrollbar, to immediately see which parts of the file were changed compared to
git and/or the last time you opened it. Can Vim do this?

Thanks!

~~~
SeoxyS
The CtrlP plugin will make opening these files a breeze. If you just trigger
it and type palette.cpp, it should be the first match.

~~~
Symmetry
Better, you can type palete.cpp and it should still be the first match.

------
fatbird
Every time I read an article like this, it's how a power user installs an
array of plugins and customizations to really soup up Vim, which to me kind of
misses the point. If you want that level whiz-bang, use Coda or Sublime Text 2
or Eclipse or whatever.

I don't recall where I saw this, but someone advised disabling syntax coloring
in your editor to remove a crutch (and, secondarily, to visually simplify your
environment). I've tried this with Vim and it's surprisingly nice [0]. You
have to read the code more closely, and think more carefully about what's on
screen, and this has the effect of focussing me more. Simplifying my
environment, making it more sparse, but always having the power of Vim
available, makes for a really potent, semi-distraction-free environment.

[0] Well, mostly. I leave it on in order to have three colors used: a good
contrast color for code, a second contrast color for strings, and a third,
very low-contrast color for comments and line numbers so that, if I want to
see those things, I can look for/at them, but if I don't, they're easy to
ignore. Likewise, visually distinguishing between strings and code continues
to be really useful.

~~~
gnosis
_"If you want that level whiz-bang, use Coda or Sublime Text 2 or Eclipse or
whatever. I don't recall where I saw this, but someone advised disabling
syntax coloring in your editor to remove a crutch (and, secondarily, to
visually simplify your environment)."_

Perhaps you might enjoy using ed...

    
    
      From: patl@athena.mit.edu (Patrick J. LoPresti)
      Sender: news@athena.mit.edu (News system)
      Subject: The True Path (long)
      Date: 11 Jul 91 03:17:31 GMT
      Newsgroups: alt.religion.emacs,alt.slack
      
      When I log into my Xenix system with my 110 baud teletype, both vi
      *and* Emacs are just too damn slow.  They print useless messages like,
      'C-h for help' and '"foo" File is read only'.  So I use the editor
      that doesn't waste my VALUABLE time.
      
      Ed, man!  !man ed
      
      ED(1)               UNIX Programmer's Manual                ED(1)
      
      NAME
           ed - text editor
      
      SYNOPSIS
           ed [ - ] [ -x ] [ name ]
      DESCRIPTION
           Ed is the standard text editor.
      ---
      
      Computer Scientists love ed, not just because it comes first
      alphabetically, but because it's the standard.  Everyone else loves ed
      because it's ED!
      
      "Ed is the standard text editor."
      
      And ed doesn't waste space on my Timex Sinclair.  Just look:
      
      -rwxr-xr-x  1 root          24 Oct 29  1929 /bin/ed
      -rwxr-xr-t  4 root     1310720 Jan  1  1970 /usr/ucb/vi
      -rwxr-xr-x  1 root  5.89824e37 Oct 22  1990 /usr/bin/emacs
      
      Of course, on the system *I* administrate, vi is symlinked to ed.
      Emacs has been replaced by a shell script which 1) Generates a syslog
      message at level LOG_EMERG; 2) reduces the user's disk quota by 100K;
      and 3) RUNS ED!!!!!!
      
      "Ed is the standard text editor."
      
      Let's look at a typical novice's session with the mighty ed:
      
      golem> ed
      
      ?
      help
      ?
      ?
      ?
      quit
      ?
      exit
      ?
      bye
      ?
      hello? 
      ?
      eat flaming death
      ?
      ^C
      ?
      ^C
      ?
      ^D
      ?
      
      ---
      Note the consistent user interface and error reportage.  Ed is
      generous enough to flag errors, yet prudent enough not to overwhelm
      the novice with verbosity.
      
      "Ed is the standard text editor."
      
      Ed, the greatest WYGIWYG editor of all.
      
      ED IS THE TRUE PATH TO NIRVANA!  ED HAS BEEN THE CHOICE OF EDUCATED
      AND IGNORANT ALIKE FOR CENTURIES!  ED WILL NOT CORRUPT YOUR PRECIOUS
      BODILY FLUIDS!!  ED IS THE STANDARD TEXT EDITOR!  ED MAKES THE SUN
      SHINE AND THE BIRDS SING AND THE GRASS GREEN!!
      
      When I use an editor, I don't want eight extra KILOBYTES of worthless
      help screens and cursor positioning code!  I just want an EDitor!!
      Not a "viitor".  Not a "emacsitor".  Those aren't even WORDS!!!! ED!
      ED! ED IS THE STANDARD!!!
      
      TEXT EDITOR.
      
      When IBM, in its ever-present omnipotence, needed to base their
      "edlin" on a UNIX standard, did they mimic vi?  No.  Emacs?  Surely
      you jest.  They chose the most karmic editor of all.  The standard.
      
      Ed is for those who can *remember* what they are working on.  If you
      are an idiot, you should use Emacs.  If you are an Emacs, you should
      not be vi.  If you use ED, you are on THE PATH TO REDEMPTION.  THE
      SO-CALLED "VISUAL" EDITORS HAVE BEEN PLACED HERE BY ED TO TEMPT THE
      FAITHLESS.  DO NOT GIVE IN!!!  THE MIGHTY ED HAS SPOKEN!!!
      
      ?

~~~
fatbird
That's awesome.

~~~
snogglethorpe
... and it's from the Emacs distribution ($EMACS_SRC/etc/JOKES)... :]

------
jason_slack
Wow. I wish I had this exact setup. I have never been good at configuring Vim
and the SPF-13 VIM distro is wonky.

Would save me from buying Sublime

~~~
slurgfest
Try using Vundle to add one plugin at a time!

~~~
jason_slack
Good idea. Thanks for the idea.

------
mathnode
In Star Trek the next generation; as different users interacted with different
physical platforms (tablets, desk consoles, wall panels, tablets, voice
activated devices, "desktops", etc), the work space would adapt to it's
physical medium....so....I'm sold!

------
snarfy
My new favorite toy: <http://gh.codehum.com/nosami/Omnisharp/>

It's 'real' intellisense for Vim/C#. It's fairly new and rough around the
edges, but works great once you get it going.

~~~
sfvermeulen
I've been looking for something like this for months. I've also never heard of
easymotion or YouCompleteMe. How is it that I've been out of the loop for all
these things ??

------
johncoltrane
netrw comes by default. No need to install NERDTree.

~~~
benmills
I've recently uninstalled NERDTree in favor of netrw and I've been presently
surprised at how little I miss NERDTree and how much more productive I am on
default vim installations.

~~~
slurgfest
Was NERDTree making you unproductive? How?

~~~
williamdix
It's not that NERDTree makes one unproductive. It's that using NetRW on
default vim installations allows you to get going without installing NERDTree.

------
mihaifm
Instead of NERDTree you might want to try Vimpanel, it's based on NERDTree but
much more evolved, and instead of using :bprev/:bnext you might want to try
Bufstop, it uses history instead of the buffer list to get you to the previous
buffer. I made these to get around some limitations for some plugins that
everyone seems to suggest.

<https://github.com/mihaifm/vimpanel> <https://github.com/mihaifm/bufstop>

------
mats_rauhala
Am I the only who tries not to override default commands? It's not like I use
them all, but I might learn it at some point, and I want to have them
available.

~~~
tomlu
As a rule of thumb you are right, but in the particular case of s, S I think
it's OK. They are pretty darn redundant.

------
welder
My vimrc file with step-by-step instructions for installation:

<https://github.com/alanhamlett/Alan-vimrc>

Some features in my vimrc file:

* Code folding for bracket or indention based languages

* Edit multiple files in tabs using minibufexpl plugin

* Using the Solarized color scheme

* Using Vundle for plugin management (apt-get for Vim plugins)

* Common swp, backup, & view directories (No more ~ files left around)

* Useful defaults (spaces instead of tabs, remove trailing newlines, etc.)

------
scott_s
I use MacVim for editing files locally on my Mac:
<http://code.google.com/p/macvim/>

------
kunai
> With a modern, 256-color terminal like iTerm2 or Gnome Terminal, it will
> even look like gVim

Uh, I use xterm...

It's obsolete, I know, but it's still the fastest.

~~~
dysoco
Fastest? Like I'd realize the speed difference between xterm, urxvt or even
Gnome Terminal.

~~~
kunai
Trust me, when you have really crappy hardware (Intel Atom 1.3GHz w/ 512MB
mem), you will notice the difference. Execution of commands that takes 2-3
seconds on Gnome Terminal will be nearly instant on xterm.

~~~
grn
Is rxvt slower? Recently I switched from xterm to rxvt-unicode and it's really
great!

~~~
kunai
Not sure... I'll have to give it a go to see if it really is.

------
lightblade
Here are my 2 cents

set undofile " This creates a undo file that persists your undo history when
the file gets closed

imap >> <ESC> " Double right arrow to escape from insertion mode. This is
faster and more comfortable (at least for me) than to reach for tab key for
some people

set clipboard=unnamed " This is bridges between your Vim yanks and your system
clipboard

~~~
grn
undofile sounds great! I didn't know about it.

Some people use jj to go to the normal mode. Personally I remapped Caps Lock
to Escape in my whole system, so I can go to normal mode easily.

You can yank to the system clipboard by providing appropriate register to yank
into. You do that by pressing "* before the yank command (e.g. "*yy to yank
the current line).

~~~
docwhat
I have some code to keep the undo/backup/swaps in a sane place...
[http://stackoverflow.com/questions/4331776/change-vim-
swap-b...](http://stackoverflow.com/questions/4331776/change-vim-swap-backup-
undo-file-name/9528322#9528322)

------
delambo
Recently, I made the switch to vim from Sublime Text and I have installed some
of the same tools. So far, I've committed to vim, but I have found that the
plugins for file searching, linting, etc. are easier to use, more intuitive,
and less painful to setup in Sublime Text.

------
kidambisrinivas
Does any vim plugin support context sensitive auto-complete like Visual Studio
(auto-complete only with variables that are alive in the current block of
code)? I code in perl and am currently using ctags for autocomplete, but it
doesnt autocomplete based on the context.

~~~
docwhat
My .vimrc does this. I haven't used it much in perl (mainly bash, ruby, and
python) but it should work fine.

[https://github.com/docwhat/homedir-
vim/blob/master/vimrc/.vi...](https://github.com/docwhat/homedir-
vim/blob/master/vimrc/.vimrc)

The important bits are vim's built-in omnicomplete and neocachecompl

Omnicomplete by itself isn't bad. I haven't seen any excellent documentation
explaining how it all works, but even without my .vimrc I use C-X-f a lot to
complete filenames.

Ciao!

------
Bjartr
Minor nitpick, but can any terminals do squiggly underlines or is that still a
gVim only feature?

~~~
kunai
Squiggly underlines? What, do you mean:

    
    
        1 class Hello
      ~
      ~
      ~
      ~
      ~
      --INSERT--
    

Like that? Of course; heck, even xterm does that fine. If you were referring
to something else, I'm not too sure...

EDIT:

Never mind, now I know what you're talking about. No, I don't think you can
get those in terminal vim, but I'm pretty sure there is a plugin for it.

------
grn
I can recommend CtrlP (or Command-T). I can't imagine navigating in a project
without them. They also have great buffer navigation. Personally I mapped
<leader>t to CtrlP file search, and <leader>b to CtrlP buffer search
(:CtrlPBuffer).

------
ichinaski
My favourite ones:

" Make Y behave like other capitals

nnoremap Y y$

" Reselect visual block after indent/outdent

vnoremap < <gv

vnoremap > >gv

~~~
tomlu
Curious - what's the point of retaining the selection after indenting?

~~~
jdonaldson
Sometimes you want to indent more than once. This remap is fine, but the
idiomatic way to do this is just to use a period to repeat the last command.
It doesn't hurt to get used to that.

~~~
verroq
Enter a number then any command to repeat it as many times as you want.

~~~
docwhat
Sometimes it's easier to see things line up.

------
pseut
I'm disappointed no one's mentioned digraphs yet. I've used emacs for years,
but I'm starting to use vim now because ctrl-k G* etc is just so easy (I type
a lot of math).

~~~
oddthink
If that's your only reason, stick with emacs but use evil-mode. I flip-flop
between liking evil-mode (when I'm mostly just editing stuff) and preferring
standard emacs keybindings (when I'm switching a lot between shells, dired,
interactive sessions, etc.)

------
fghh45sdfhr3
With other people's code I prefer to use something like
<http://astyle.sourceforge.net/> on the command line.

------
moron4hire
One of the things that I really love about Vim is that it's the same on every
platform, including Windows. Hell, it's the same on my Android device.

------
jagguli
Has top level windows been implemented yet. It's been on the todo for a long
time so has a lot other new feature requests.

~~~
jagguli
Basically can you create one vim server and make multiple connections to it,
sharing the same session and buffers. Like how emacsclient works.

------
dreamdu5t
No Command-T!? FAIL.

~~~
Syssiphus
That's what CtrlP is for.

------
papsosouid
I use nvi, and have tried to switch to vim a dozen or so times over the years.
But there are so many irritating little quirks and misfeatures and annoyances
that I can never manage to fix. Does anyone know of a guide to getting a sane,
non-broken vim working with some basic plugins like syntastic? Last time I
tried I couldn't bind F-keys for some reason, I couldn't get syntastic's error
marking column to stay on instead of shifting my text back and forth all the
time, I couldn't get auto-complete mapped to tab properly, and a few other
things I can't remember now. I eventually gave up again as the extra
functionality of vim ends up being counter-productive when none of it works
right.

~~~
slurgfest
It sounds like you want vim features. But vi compatibility mode is probably
not consistent with these. Mapping f-keys should work fine in a GUI vim, but
in a terminal F-keys may depend on configuring the terminal. You don't have to
use syntastic if it doesn't work right for you, you can just use individual
checker plugins or set makeprg and use :make. Mapping auto-complete to tab
depends on not having multiple plugins fighting over the key. Most of this is
a matter of particular plugins, not vim itself.

~~~
papsosouid
Right, I want some of the vim features, mainly plugins. I don't enable vi
compatibility, it isn't even remotely vi compatible and it just breaks stuff.
I want syntastic, that's the primary motivation for trying to get vim working.
I just want it to be helpful instead of irritating. No plugins are messing
with tab, I am just trying to get it to work using a normal mapping.

