Hacker News new | comments | show | ask | jobs | submit login
Ask HN: What's in your .vimrc file?
123 points by Xichekolas 2824 days ago | hide | past | web | 67 comments | favorite
Other than the default stuff of course. As you can see, my additions are quite pathetic so far (only been into vim for a few months):

  set expandtab
  set sts=2
  if v:progname =~? "gvim"
    colorscheme twilight
  endif



I just keep swap files and backup ones in my .vim/ directory

  set backupdir=~/.vim/backup
  set backup
  set directory=~/.vim/tmp
This to see line numbers on the left (i find it a bit more readable instead of watching at the bottom-right)

  set number
added a simple way to speedup my writing with (I know it's crappy but it works ...until you need to add just one bracket/quote)

  " autocomplete parenthesis, brackets and braces
  inoremap ( ()<Left>
  inoremap [ []<Left>
  inoremap { {}<Left>
  
  " autocomplete quotes
  inoremap	'  '<Esc>:call QuoteInsertionWrapper("'")<CR>a
  inoremap	"  "<Esc>:call QuoteInsertionWrapper('"')<CR>a
  inoremap	`  `<Esc>:call QuoteInsertionWrapper('`')<CR>a
  
  function! QuoteInsertionWrapper (quote)
    let col = col('.')
    if getline('.')[col-2] !~ '\k' && getline('.')[col] !~ '\k'
      normal ax
      exe "normal r".a:quote."h"
    end
  endfunction
and mapped f1/f2 to switch buffer

  noremap <f1> :bprev!<CR>
  noremap <f2> :bnext!<CR>
Some of this wall of text was stolen from a nice, but a bit too big, vimrc i found somewhere

If you need something specific try http://vim.wikia.com/


Do this to prevent yourself from learning the arrow keys while learning:

  map <down> <nop>
  map <left> <nop>
  map <right> <nop>
  map <up> <nop>   

  imap <down> <nop>
  imap <left> <nop>
  imap <right> <nop>
  imap <up> <nop> 
(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=%<%F\ %h%m%r%=%-14.(%l,%c%V%)\ %P

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)


Most of what I use was copied from this excellent site: http://www.vi-improved.org/vimrc.php


I wonder why you were voted down (not answering OP question to the letter?) -- that's one of the nicest references I've seen.


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.


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.


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


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         " <TAB> 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"


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, but it's what I'm used to.


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


Don't get me wrong, there are many conveniences that I DO use.

However, for editors I've just always preferred to stay as basic and reliable as possible. vi is quick, easy, simple and has been on every *nix machine that I've ever walked up to. Relying on customizitions beyond that is, for me, sub-optimal.

I have had more than a handful of workdays that spanned 2 or 3 or 4 continuous days with little or no sleep at all (although thankfully not in several years). In those cases we were usually recovering from planned maintenance gone wrong. In one case I was trying to edit/update some config files, force software upgrades into a bunch core switches and dispatch pilots with spare parts. It was helpful, to me, to be able to rely on the basics as I hopped through SSH sessions from server to server (but, I did use host keys to speed my logins).

My case is moreso for edits and small customizations and not long sessions of coding, so I really don't NEED a whole lot beyond the basics of what I can memorize.


> when it's 3AM and you've been up for 67 consecutive hours

That can't be healthy. My longest stretch (age 17) was something like that and I fell down half a flight of stairs without waking up when going home.

Please be careful.


Out of curiosity, why not just wget or curl -O a file from a webserver?


Most of my work the last few years has been in the compliance and IT or Physical security (or converged) space.

The machines I am working on are not my own, and often have no access to the Internet directly.

However, I'm generally doing more "editing" than "coding" so it's not a major limitation anyway.


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!<CR>:set paste?<CR>
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.


Mainly for python scripting, but works decently for most editing I do.

  syntax on " syntax highlighting
  set tabstop=4 " PEP-8 uses 4 spaces per indentation level
  set shiftwidth=4 " shifting (PEP-8)
  set expandtab " spaces instead of tabs (PEP-8, and just bettter in general)
  filetype on " file type detection
  filetype indent on " special indentation rules for file type
  filetype plugin on " auto-completion rules for file type
  set hls " highlight search terms (:noh to turn off temporarily)
  set ignorecase " ignore case for searches (:set noignorecase to turn off)
  set incsearch " search as you type
  colorscheme darkblue " slightly nicer colour scheme
  set scrolloff=15 " keep 15 lines of context on both sides of cursor when scrolling
http://github.com/paulgb/settings/blob/9ebf793bcf202589c74f3...


Some I like:

  " Keep cycled-away buffers open (preserving undo, 
  " allowing buffer switch without write)
  set hidden

  " Facilities for handling pasting into vim, preserving
  " indentation of the pasted text.
  " This will make <F4> start paste mode and <F5> stop paste mode.
  " Note that typing <F5> in paste mode inserts <F5>, since in paste
  " mode everything is inserted literally, except the 'pastetoggle' key
  " sequence.
  map <F4> :set paste<CR>
  map <F5> :set nopaste<CR>
  imap <F4> <C-O>:set paste<CR>
  imap <F5> <nop>
  set pastetoggle=<F11>

  " Toggle line-numbers with key sequence Ctrl-N-N:
  nmap <C-N><C-N> :set invnumber <CR>

  " Consolidate swapfiles to keep working directories clean
  set directory=~/.vim/swap


Been through some changes lately - this is the trimmed down of my .gvimrc (MacVim). " window settings set lines=70 set columns=200 set fileencoding=utf8

    set incsearch
    set ignorecase
    set hlsearch
    
    " make the status line more useful
    set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
    set nocompatible
    
    " backspace mode
    set bs=2
    
    " highlitt current line and add line numbers
    set cursorline
    set number
    
    " yummy
    set guifont=Monaco:h11.00
    
    " turn off the scrollbars and the rest of the crap
    set guioptions=eg
    
    
    ""set foldenable
    ""set foldmethod=indent
    filetype plugin on
    filetype on
    
    " autoindenting
    set cindent
    set smartindent
    set autoindent
    
    " display improvements
    set list
    " show indents
    set listchars=tab:\.\ ,trail:-
    set ruler
    set showcmd
    " i use tabs instead of spaces, wanna make something of it?
    set noexpandtab
    set tabstop=4
    set shiftwidth=4
    set softtabstop=4
    
    " temp files
    set backupdir=~/.vim/bak
    set directory=~/.vim/tmp
    " colorz
    syntax on
    colorscheme herald " molokai, zenburn, darkburn, vibrantink
    
    " PLUGINZ
     " allml settings
    let g:allml_global_maps = 1
    let g:HiMtchBrkt=1
    let g:SCMDiffCommand="/opt/subversion/bin/svn"
    
    inoremap <C-B> <ESC>:call PhpDocSingle()<CR>
    nnoremap <C-B> :call PhpDocSingle()<CR>
    vnoremap <C-B> :call PhpDocRange()<CR> 
    
    " PHP specific fixes
    " highlights interpolated variables in sql strings and does sql-syntax highlighting. yay
    autocmd FileType php let php_sql_query=1
    " does exactly that. highlights html inside of php strings
    autocmd FileType php let php_htmlInStrings=1
    " discourages use oh short tags. c'mon its deprecated remember
    autocmd FileType php let php_noShortTags=1
    " settings for cake
    au BufNewFile  *.ctp set filetype=php
    au BufRead *.ctp set filetype=php


set nocompatible

set backspace=indent,eol,start

if has("vms") set nobackup else set backup endif set history=50 set ruler set showcmd set incsearch

map Q gq

inoremap <C-U> <C-G>u<C-U>

if has('mouse') set mouse=a endif

if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif

if has("autocmd")

  filetype plugin indent on

  augroup vimrcEx
  au!

  autocmd FileType text setlocal textwidth=78

  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END
else

  set autoindent	       
endif

if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis endif

colors zenburn

:filetype plugin on

set et set sw=4 set smarttab set lbr

set t_Co=256

set backupdir=./.backup,.,/tmp set directory=.,./.backup,/tmp

set nobackup set nowritebackup

set number

compiler ruby

autocmd Filetype ruby source ~/.vim/ruby-macros.vim nnoremap <silent> <F8> :TlistToggle<CR>

let Tlist_Auto_Open=1

:set title titlestring=%<%f\ %([%{Tlist_Get_Tagname_By_Line()}]%)

set virtualedit=all


Mine, though I've (mostly) moved to emacs these days:

  set nocompatible
  source $VIMRUNTIME/vimrc_example.vim
  source $VIMRUNTIME/mswin.vim
  behave mswin
  set tabstop=4
  set shiftwidth=4
  set gfn=Consolas:h10:cANSI

  set number
  set cin!

  colorscheme evening

  map <silent><A-Right> :tabnext<CR>
  map <silent><A-Left> :tabprevious<CR>
  map <F10> :browse tabnew<CR>

  set diffexpr=MyDiff()
  function MyDiff()
      let opt = ''
      if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
      if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
      silent execute '\"!C:\Program Files\vim\diff\" -a ' . opt . v:fname_in . ' ' . v:fname_new . ' > ' . v:fname_out
  endfunction
EDIT: Updated formatting.


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}


Here are just a couple things I find really useful day to day. I used to have a timeout that would revert to normal mode from insert mode after about 30 seconds if idle, but I got tired of that after about six months and just got in the habit of hitting Escape when I finished with an insert action. I did it just now, even though this is a textarea.

  " For (ab)use with :sp
  map <C-j> <C-W>j<C-W>_
  map <C-k> <C-W>k<C-W>_
  set wmh=0 so=999 winheight=999

  nnoremap i :noh<CR>i

  " \s is global-replace-this-word
  :nnoremap <Leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>


The one addition to my .vimrc that I can't live without:

  nnoremap <Space> :


This just made my day :) Thanks


Map some "leader" commands for common operations, eg:

  let mapleader=','
  let g:mapleader=','

  nmap <leader>w :w!<cr>
  nmap <leader>q :q<cr>
  nmap <leader>f :find<cr>
  map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
  nmap <leader>m :make<cr>

  " cut & paste
  map <leader>c "+y
  map <leader>x "+d
  map <leader>v "+p
Also quicker window navigation:

  map <C-j> <C-W>j
  map <C-k> <C-W>k
  map <C-h> <C-W>h
  map <C-l> <C-W>l


The interesting stuff only:

    set showbreak=>\ 
    set wildignore=*.bak,*.pyc,*.swp
    set wildmenu
    set wildmode=list:longest
    
This is actually quicker than reaching for ESC most of the time:

    inoremap <C-s> <ESC>
    vnoremap <C-s> <ESC>
Tab switching:

    noremap <C-l> gt
    noremap <C-h> gT
Something useful for syntax file writing:

    noremap <F6> :echo synIDattr(synID(line("."), col("."), 1), "name")<CR>


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!<CR>
  map ,s :w<CR>
  map ,w :x<CR>
  nmap <silent> <F6> :set number!<CR>
and ctags are especially useful


Consider doing this instead:

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

  map <Leader>q :q!<CR>
  map <Leader>s :w<CR>
  map <Leader>w :x<CR>
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.


Good idea, I'll have to add that.


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


Reformat hex-dumps into 32-bit words, 8 words per line.

nmap H :s/\v(\S{8})/\1 /g<CR>:s/\v((\S{8} ){8})/\1<C-V><CR>/g<CR>:nohl<CR>


  "tab completion of words in insert mode
  function InsertTabWrapper()
        let col = col('.') - 1
        if !col || getline('.')[col - 1] !~ '\k'
            return "\<tab>"
        else
            return "\<c-p>"
        endif
  endfunction

  inoremap <tab> <c-r>=InsertTabWrapper()<cr>



I do a lot of copying/pasting from my browser (and other random places), so these mappings make my life easier:

  " copy/paste with the system clipboard
  map ^P "+gP
  map ^C "+y
Also this, for dealing with DOS-style stuff:

  " map <ctrl>+s to remove ^M from the ends of lines
  map ^S :%s\/^M\/\/g


  map ^C "+y
Ugh. I couldn't do that. C-c is a shortcut to exit Insert Mode or to stop a command (similar to C-g usage in Emacs or mutt).

  map ^S :%s\/^M\/\/g
Be careful with that on terminals. C-s is usually mapped in with flow control on terminals.


http://github.com/msanders/vim-files/blob/master/.vimrc

Most of it's just my quirks but I think there's some useful bits in there. My vim setup is _heavily_ customized, for better or for worse.


I like autocomplete in my .vimrc

function! InsertTabWrapper() let col = col('.')-1 if !col || getline('.')[col-1]!~'\k' return "\<tab>" else return "\<C-P>" endif endfunction inoremap <tab> <C-R>=InsertTabWrapper()<CR>


Adopted from the mighty tpope's vimrc file, and somewhat dependent on some of the plugins (also in my dotfiles repo on github)

http://github.com/csexton/dotfiles/blob/master/home/vimrc


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.


Indeed! I can't do it any more, just filled me with so much hate... It's like people use the spacebar just to think.

/rant ;)


And to answer the poster, I tend to just use the default vim. I'm bouncing around machines so much that I don't bother setting anything up on my main one that I'll miss on the others...


My cure for that is putting my .vimrc on my site; then, from a foreign machine, I just do:

wget -O ~/.vimrc http://lucasoman.com/vimrc

And just like that, I'm in my comfort zone. Of course, this doesn't cover plugins and such, but I don't use those very often.


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 <silent> ,R :cal<SID>RemoveWhitespace()<cr>


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'.


It's a little outdated, but I spent some time on tweaking it: http://amix.dk/vim/vimrc.html

I specially like:

  map <space> /
  map <c-space> ?
And the parenthesis/bracket expanding.


Mine's not very advanced; .gvimrc for MacVim:

  set guifont=Pragmata:h14
  set guioptions=egmrLt
  set nohlsearch
  set number
  set ts=3
  colors vividchalk
  syntax on
Pragmata is a delicious, delicious font.


90 Euros for a font? Whoa.


Put your vimrc under revision control. Watch it grow from 5 lines to over 500 in the span of a year.

It seems like switching the developer bit in the brain for config files does wonders for environment personalization.


http://github.com/latortuga/personal/blob/master/_vimrc

I've been messing with code folding lately, cool stuff.


Lots: http://github.com/cdmwebs/dotfiles/raw/master/vimrc

Probably time to clean it up a bit.



perhaps of interest:

  " for vertical split, with the pipe dividers hidden
  :hi clear vertsplit
  :hi vertsplit ctermbg=Black ctermfg=Black

  " quit quits all
  :nmap :q :qa
  :nmap :wq :wqa

  " H/L go to beginning/end of line without moving fingers
  :nmap H 0
  :nmap L $

  " turn off matching paren highlighting
  let loaded_matchparen = 1


Why don't you use paren matching?



Mine is a behemoth, so I have pasted it here:

http://pastebin.com/f6e58888a


  syntax on
  set background=dark
  set et
  set ts=4
  set ruler
  set shiftwidth=4


Sorry about how long this is!! This is the culmination of about 1.5 years using VIM as my exclusive text editor for web development. When I started I was using PHP and now I'm using Ruby on Rails. If you have any general questions about VIM, specific questions about my .vimrc, or anything related, ask in the comments and I'll try to answer:

set fo=tcqln ic nohls nu sc scs sm tm=200 wim=longest,list nonumber

let g:explDetailedList=1

" store all of your vim swp files in one place, make sure this directory exists

set backupdir=/Users/{YOUR_USERNAME}/vim_swp

set directory=/Users/{YOUR_USERNAME}/vim_swp

set bs=indent,eol,start

set hlsearch

" Use incremental searching

set incsearch

" Set standard setting for PEAR coding standards

set tabstop=4

set shiftwidth=4

" Auto expand tabs to spaces

set expandtab

" Auto indent after a {

set autoindent

set smartindent

" Linewidth to endless

set textwidth=0

" Do not wrap lines automatically

set wrap

" DO NOT Show line numbers by default

set nonumber

" Jump 5 lines when running out of the screen

set scrolljump=5

" Indicate jump out of the screen when 3 lines before end of the screen

set scrolloff=3

" Repair wired terminal/vim settings

set backspace=start,eol

" This function determines, wether we are on the start of the line text (then tab indents) or

" if we want to try autocompletion

function InsertTabWrapper()

    let col = col('.') - 1

    if !col || getline('.')[col - 1] !~ '\k'

        return "\<tab>"

    else

        return "\<c-p>"

    endif
endfunction

" Remap the tab key to select action with InsertTabWrapper

inoremap <tab> <c-r>=InsertTabWrapper()<cr>

" set list

" set listchars=tab:>-,trail:-

" set listchars=tab:>-,trail:-,eol:$

set ignorecase " caseinsensitive searches

set showmode " always show command or insert mode

set ruler " show line and column information

set showmatch " show matching brackets

set formatoptions=tcqor

set whichwrap=b,s,<,>,[,]

syntax on

" Added by chris

" from http://items.sjbach.com/319/configuring-vim-right

set hidden

set history=1000

nnoremap ' `

nnoremap ` '

set smartcase "is case sensitive only if there's a capital letter

set title

" enables matching if/elseif/else/etc., sort of works

runtime macros/matchit.vim

"from http://blog.learnr.org/post/59098925/configuring-vim-some-mo...

map H ^

map L $

" End Added by chris

let loaded_matchparen = 1

nmap <F6> <ESC>:call LoadSession()<CR>

let s:sessionloaded = 0

function LoadSession()

  source Session.vim

  let s:sessionloaded = 1
endfunction

function SaveSession()

  if s:sessionloaded == 1

    mksession!

  end
endfunction

autocmd VimLeave * call SaveSession() "Reopen your session with 'vim -S Session.vim'


I love the scrolljump and scrolloff, never seen those before...also I think you may have just changed my life by showing me how to use sessions.


syntax on

color zellner

set cursorline

set cursorcolumn

set nu

set autoindent

set tabstop=4

map <C-n> <ESC><ESC>:tabnew<CR>

map <C-left> <ESC><ESC>:tabprev<CR>

map <C-right> <ESC><ESC>:tabnext<CR>

map <C-down> <ESC><ESC>:tabclose<CR


:set viminfo="" :set modeline ai et si sw=8 ts=8 :syntax off


$ wc .vimrc

427 2342 16457 .vimrc

Way too much


  " menu for encoding
  set wildmenu
  set wcm=<Tab>
  set ts=4
  menu Encoding.koi8-r   :e ++enc=koi8-r<CR>
  menu Encoding.windows-1251 :e ++enc=cp1251<CR>
  menu Encoding.utf-8                :e ++enc=utf-8 <CR>
  map <F8> :emenu Encoding.<TAB>


Characters. Lots of characters.


    set vi




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: