Live data from Hacker News

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

news.ycombinator.com

21–30 of 69 posts

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

#22
Most of my .vim folder and .vimrc came from andreiz and tomasr. I have it committed to github for easy download on any server I'm working on. http://github.com/bnmrrs/dotfies if anybody would like to check it out.

  map ,q :q!
  map ,s :w
  map ,w :x
  nmap   :set number!
and ctags are especially useful

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

#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).

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

#24
A good line to memorize:

  :set et sts=4 sw=4 ts=4

  et  = expandtab (spaces instead of tabs)
  ts  = tabstop (the number of spaces that a tab equates to)
  sw  = shiftwidth (the number of spaces to use when indenting
        -- or de-indenting -- a line)
  sts = softtabstop (the number of spaces to use when expanding tabs)
Also you might want to move 'colorscheme twilight' into the ~/.gvimrc file instead; it makes the .vimrc file cleaner when you separated out all of the gui-specific stuff.

My full vimrc and setup is here: http://github.com/bsandrow/vimc

{edit} Another good one:

  noremap Y y$
By default Y is mapped to the equivalent of yy. This makes Y act like the 'copy/yank' equivalent of D. {/edit}

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

#26
post #22

Most of my .vim folder and .vimrc came from andreiz and tomasr. I have it committed to github for easy download on any server I'm working on. http://github.com/bnmrrs/dotfies if anybody would like to check it out. map ,q :q! map ,s :w map ,w :x nmap :set number! and ctags are especially useful

Consider doing this instead:

  let mapleader = ","    " 
  let g:mapleader = ","

  map q :q!
  map s :w
  map w :x
The mapleader is basically used to give your custom keybindings a separate namespace. It looks like that's what your doing here, but using the variable makes it easier to change later f you want.

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

#28
I think :set wildmenu is great, especially for relative newbies such as myself:

  command! CD cd %:p:h " change to current buffer's directory
  set incsearch " Incremental search
  set hlsearch " Highlight search
  set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
  set nowritebackup " no stupid backup files
  set noswapfile    " no stupid recovery files
  set wildmenu " it's wild
  set visualbell
  set fileformat=unix

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

#29
post #16

Nothing. I work on many different systems from time to time. I don't like to get too used to things that aren't universal. I have found out (the hard way) that relying on convenience can bite you in the ass when it's 3AM and you've been up for 67 consecutive hours and you execute some keystrokes from habit and they don't do what you expected. I'll admit, I probably cripple my productivity overall for working this way…

> I have found out (the hard way) that relying on convenience can bite you in the ass when it's 3AM and you've been up for 67 consecutive hours and you execute some keystrokes from habit and they don't do what you expected.

You really could say that about anything. You could say that one shouldn't program in dynamically-typed languages because 'one day' you'll have to program in a statically-typed language and all your habits will 'bite you in the ass.' I think that you should really blame this part:

> and you've been up for 67 consecutive hours

Unless you're trying out for the SEALS, I don't think this is normally part of any job description. And I hardly think this is some sort of 'common case' that you should be planning for. There's a difference between preparing for the worst and over-preparing for the worst.

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

#30
This crap has accumulated over the years, so I'm not sure if any of it is obsolete or unneeded, but here's what I found in mine:

  set expandtab         " Convert tabs to spaces
  set tabstop=4         "  four spaces
  set shiftwidth=4      " Shift width four spaces (for auto indent)
  set noautoindent      " Turn off autoindent by default
  set smartindent       " Use smart indent instead
  set incsearch         " Use incremental searches (cool)
  set backspace=2       " Set backspace mode to allow backspacing in insert mode
  set ruler             " Show position of cursor in status line
  set showmatch         " Show matching parens/braces when writing code
  set wh=55             " Minimum window height
  set textwidth=78      " Maximum line width when writing comments

  " Speed up response to ESC key
  set notimeout
  set ttimeout
  set timeoutlen=100

  " Make completion more like bash
  set wildmode=longest,list

  " Cure hangs during compiles?
  set swapsync=

  " For fuck's sake, don't throw away the indent when i hit #
  inoremap # X^H#

  " Disable auto-commenting of // in C/C++
  au FileType c,cpp setlocal comments-=://

  " Highlight trailing whitespace
  hi TrailingSpace ctermbg=1
  au filetype c,cpp,python match TrailingSpace "\s\+\n"
Post reply on HN