Live data from Hacker News

Ask HN: What's in your .vimrc file?

news.ycombinator.com

51–60 of 69 posts

Re: Ask HN: What's in your .vimrc file?

#53

someone mentioned listchars elsewhere, but I prefer these glyphs: set listchars=tab:»·,trail:· set list this makes it so all your tabs and trailing whitespace is visible. note, this will make you hate almost every other developer.

Here's a function I wrote to get rid of trailing white space:

    fun! s:RemoveWhitespace()
    	if &bin | return | endif
    	if search('\s\+$', 'n')
    		let line = line('.')
    		let col = col('.')
    		sil %s/\s\+$//ge
    		call cursor(line, col)
    		echo 'Removed trailing whitespace.'
    	else
    		echo 'No trailing whitespace found.'
    	endif
    endf
You can map it with:

    nn  ,R :calRemoveWhitespace()

Re: Ask HN: What's in your .vimrc file?

#54
http://bitbucket.org/natw/dotfiles/src/tip/.vimrc

some parts I haven't seen mentioned otherwise:

  set statusline=[TYPE=%Y]\ [ENC=%{&fenc}]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]
  hi StatusLine term=bold,reverse cterm=bold ctermfg=7 ctermbg=0
  hi StatusLineNC term=reverse cterm=bold ctermfg=8
gives me a nice status bar with some good info

  set t_Co=256
  colorscheme railscasts
best color scheme I've found yet, and I don't know how I lived before 256 colors

  set noerrorbells
  set novisualbell
  set t_vb=
This might be redundant, but I hate error bells SO MUCH. This might be even more important than "set nocompatible".

  map ^P :set paste!:set paste?
in python mode at least, autoindent will usually mess up pasted text

Plus the usual 4 space soft tab, autoindent stuff. I also highly suggest keeping your dotfiles in some kind of version control. It is definitely fun to see them grow, and I can't imagine working on multiple systems without it.

Re: Ask HN: What's in your .vimrc file?

#55

  colors torte
  syn on
  set expandtab
  set tabstop=4
  set shiftwidth=4
  set ruler
  set ignorecase
  set autoindent
  set smartindent
  set hlsearch
  set incsearch
  set backspace=indent,eol,start
  set laststatus=2
  autocmd BufEnter * :syntax sync fromstart
  "set hidden
  set history=1000
  runtime macros/matchit.vim
  set wildmenu
  "set wildmode=list:longest
  set wildmode=longest:full,full
  set title
  set scrolloff=3
  autocmd BufEnter *.rb :set ts=2 sw=2
  
  "let c_space_errors=1
I'm kinda unsure what good posting this will do...

Re: Ask HN: What's in your .vimrc file?

#56
Didn't we have one of these threads a little while ago? Ah yes, here we go:

http://news.ycombinator.com/item?id=821100

Here's a repost of my comment from that thread:

I've been using Vim for over ten years now, across several jobs and platforms and tasks, so my .vimrc and .gvimrc have gathered quite a bit of cruft. I keep them in a git repository along with my various other generically useful config files, and just check them out on each new machine I get an account on.

There's too much stuff in these files to describe what everything does, but there's a lot of comments, so along with the Vim online help you should be able to figure everything out:

.vimrc: http://paste.ubuntu.com/270714/

.gvimrc: http://paste.ubuntu.com/270716/

Highlights include a single key-binding for stepping through every buffer in every tab, consistent mouse-handling between console-vim and gvim, and code to automatically make gvim inherit the GNOME default monospace font.

Re: Ask HN: What's in your .vimrc file?

#57

someone mentioned listchars elsewhere, but I prefer these glyphs: set listchars=tab:»·,trail:· set list this makes it so all your tabs and trailing whitespace is visible. note, this will make you hate almost every other developer.

Going into an old codebase and just running ':set list' with just the default listchars is maddening enough. The mixes of tabs and whitespace characters is enough to drive one batty. Especially when you find files where someone was using tabs, but with the 'ts=8' or 'ts=2' rather than 'ts=4'.

Re: Ask HN: What's in your .vimrc file?

#59
post #23

Do this to prevent yourself from learning the arrow keys while learning: map map map map imap imap imap imap (There's actually a recently reported bug that causes the up arrow to do some strange things, but you get the idea).

As you say, that's a good way to force your fingers to learn the way of h, j, k and l.

I started with vi so long ago that I remember being surprised around five years ago when I accidentally discovered that vim knows about the arrow keys. So I've never had to un-learn the arrow keys.

You may want to turn them back on eventually. It's nice to be able to move the cursor without thinking about it, whether your hands are on the keyboard, over the arrow keys or on the mouse, sort of like being able to play the chord you want no matter where your hand is on the fretboard.

As for my .vimrc, there are years of settings and commands I never use and can't remember what for, like junk DNA. I enjoy discovering and sharing the occasional treat, but I've gone pretty much meat and potatoes over the years.

Depending on your setup, your ruler (:set ruler) may or may not always show the file. This will make it always show:

set statusline=%I like the tabula colorscheme, which you can find on vim.org:

colorscheme tabula

I like smartcase: set ic set smartcase

and I like the ability to override it when I search: /\Cfindonlylowercaseinstances (:help, and then look in chapter usr_27.txt)

Re: Ask HN: What's in your .vimrc file?

#60

Earlier quoted context omitted.

Downvoting seems to be in fashion lately. I've noticed a lot of perfectly good comments voted down without any apparent cause, only to float back up later on. This is something of the last two weeks or so, before that it was happening too, but much less frequently.

Could it have something to do with the mechanism for voting and the prevalence of iPhones? I think it would be the cats meow if when detecting the iPhone or any mobile browser the down vote arrow was moved to the right of the title bar area. I say this because my fat fingered attempt at upvoting a comment has the reverse effect of my intent on many occasion. PG, Are you still looking for a specific iPhone interface?

Me too, I've done this on occasion on my iPhone. The arrows are so small and close together. If you see capitalized words in the middle of a sentence Like this, that too is the iPhone's fault.
Post reply on HN