Hacker News new | past | comments | ask | show | jobs | submit login
Configuring vim right (sjbach.com)
72 points by kirubakaran on Nov 10, 2008 | hide | past | favorite | 27 comments



Thanks for this one: "Store temporary files in a central spot Swap files and backups are annoying but can save you a lot of trouble. Rather than spreading them all around your filesystem, isolate them to a single directory"


set backupdir=~/.vim/backup//

set directory=~/.vim/swp//

If you end your settings with double trailing // then vim will automatically use the full path to the file

so editing

/etc/X11/x.org and ~/x.org won't clobber each other in your swap directory.


Tim Pope, author of Rails.vim, surround.vim and a bunch of other Vim Scripts has his config files at http://git.tpope.net/ he has some stuff I've never seen anywhere else.

I still like Emacs more though.


I know this is way off on a tangent, but as a guy who keeps trying to pick up emacs and ends up going back to Vim; I really wish there was a place out there where people had their .emacs posted with comments so I could see some ways that people are configuring their emacs.

I have copied full .emacs files previously, but it'd be cool to see some snippets somewhere.


Yeah, I'm with you on this one. I felt like it was a prerequisite for useful CL/Clojure work, though it probably isn't really.

It'd be especially nice to see someone's who'd used Vim for 5+ years and then switched so there's setups for maybe Viper, etc.


A hacker website full of emacs users, and I'm the first to post this link? Unbelievable.

http://www.dotemacs.de/


I think the dirty secret around here is that a lot of us are Textmate and gVim users (amongst other ...ahem... editors)

Anyways, that's a great link; although it looks like they need to fix their links to gnu.org. Thanks!


http://emacswiki.org is a great source of emacs snippets, and it has really active community.


My .vimrc is here:

http://albert.rierol.net/vim_tricks.html

... along with some tips.

[oops misread your comment. My .emacs is here: http://albert.rierol.net/emacs ]


I'm giving emacs a valuation right now. I mostly code very short numerics things up that don't really take much keyboard-fu, but i've always thought a lot about the editor I use. I used to use Vim, but I figured I'd give emacs a try and see if I like it. I get pretty annoyed with the weirdness of the different keyboard shortcut combos, but I'm getting used to them slowly but surely. I kinda miss Vim though..i've been thinking of jumping ship back to Vim and spend some more time making it really customized for myself.


Emacs makes my left pinky hurt.


Are you using emacs at present or have you given up on it already? Did you swap 'Caps Lock' and 'Ctrl'?


oh ... I use vi and I haven't exactly given up on emacs


Try swapping caps and ctrl.


Thanks for the great tip, will sure try.


I did all this: http://steve.yegge.googlepages.com/effective-emacs and I am very happy.


I also find pouring over dotfiles .vimrc files uncovers many tricks I didn't know: http://dotfiles.org/.vimrc


Nice tips. As a side note - in my opinion, finding a good color scheme can also improve your enjoyability and even usability of vim. I was surprised at how much easier on the eyes some color schemes were versus the default. In addition, if you like having a default terminal look that doesn't quite transfer well to vim (such as a terminal with a little transparency which can be helpful on smaller screens since you can effectively "share" some space between your terminal and whatever you might be reading off of), having a default colorscheme will fix that too.

One very (almost overly) comprehensive place to start is at: http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/

Personally I like desert256


Quick question to the Vim experts here at HN but why is it when I start vim from the terminal (Ubuntu) it does not apply the color schemes I downloaded from Vim.org, yet when I start GVim I can see the color schemes applied?


In your terminal Vim session, type :echo g:colors_name to find out if you have a colour scheme set.

Also what version of Vim are you using? If you are using Vim-Tiny for example, it is not compiled with syntax highlighting support. Type :version to see the list of compiled features and look for '+syntax'.

Otherwise it could be your terminal emulator playing up.

Try :set t_Co to see how many colours Vim can recognise in your terminal. Ideally this should return at least '8'. If it doesn't there may be some tips in :h xterm-color.


Also, check whether you're applying the color scheme in .vimrc or .gvimrc, and check where you're turning on syntax highlighting. Remember some color schemes just look different depending whether you're in the terminal or the full GUI.


I learned something new today, from this article, with the lovely comment "Who needs .gvimrc?"

if has('gui_running')


Sounds like you may be using a colorscheme that only defines gui colors. We get plenty of "problems" like that in #vim.



i wish the matchit thing would work with ruby; i've been annoyed that % on if/do/end/etc. doesn't work like it does with languages using brackets around blocks.


I haven't used this extensively but I'm having no problems with % matching on ruby conditionals and blocks.

Maybe its because I have a .vim/syntax/ruby.vim installed. Do you?


# how to start a religious war in two easy steps

sudo rm `which vim`

sudo ln -s `which emacs` /usr/local/bin/vim




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: