3 " An example for a vimrc file.
5 " Maintainer: Bram Moolenaar <Bram@vim.org>
6 " Last change: 2006 Nov 16
8 " To use it, copy it to
9 " for Unix and OS/2: ~/.vimrc
11 " for MS-DOS and Win32: $VIM\_vimrc
12 " for OpenVMS: sys$login:.vimrc
14 " When started as "evim", evim.vim will already have done these settings.
15 if v:progname =~? "evim"
19 " Use Vim settings, rather then Vi settings (much better!).
20 " This must be first, because it changes other options as a side effect.
23 " allow backspacing over everything in insert mode
24 set backspace=indent,eol,start
27 set nobackup " do not keep a backup file, use versions instead
29 set backup " keep a backup file
31 set history=50 " keep 50 lines of command line history
32 set ruler " show the cursor position all the time
33 set showcmd " display incomplete commands
34 set incsearch " do incremental searching
35 set scrolloff=2 " keep two lines of scroll off
36 set showcmd " show the currently typed cmd at the btm right
37 set whichwrap=b,s,<,>,[,],h,l " wrap round movement keys over lines
38 set listchars=tab:⌞\ ,trail:⋅ " set a prettey visible whitespace style
39 set list " enable whitespace visibility
40 set softtabstop=2 " tabkey = 2 spaces
41 set tabstop=2 " set the width of a tab stop
43 set shiftwidth=2 " set the width of a shiftwidth (auto indent)
44 "set expandtab " all my beloved tabs gone!
45 set nu " enable line numbers
46 set ignorecase " disable case-sensitivity
47 set spelllang=en_gb " I'm british...
48 " Fix the horrible deletion of auto indents
49 inoremap <CR> <CR><Space><BS>
50 nnoremap o o<Space><BS>
51 nnoremap O O<Space><BS>
53 "Highlight Long lines (>80chrs):
54 " :let w:m1=matchadd('Search', '\%<81v.\%>77v', -1)
55 " :let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
60 " Some customisations for gvim
61 set guifont=Inconsolata,10 " A nice font for gvim
62 set guioptions-=T " Turn off the toolbar
63 set guioptions-=m " Turn off the menu bar
64 "set guioptions-=r " Turn off the scroll bars
70 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
71 " let &guioptions = substitute(&guioptions, "t", "", "g")
73 " Don't use Ex mode, use Q for formatting
76 " In many terminal emulators the mouse works just fine, thus enable it.
79 " Switch syntax highlighting on, when the terminal has colors
80 " Also switch on highlighting the last used search pattern.
81 if &t_Co > 2 || has("gui_running")
87 set lines=50 columns=100 " Have a reasonable default size
90 " Only do this part when compiled with support for autocommands.
93 " Enable file type detection.
94 " Use the default filetype settings, so that mail gets 'tw' set to 72,
95 " 'cindent' is on in C files, etc.
96 " Also load indent files, to automatically do language-dependent indenting.
98 " Put these in an autocmd group, so that we can delete them easily.
101 set autoindent " always set autoindenting on
102 " For all text files set 'textwidth' to 78 characters.
103 "autocmd FileType text setlocal textwidth=78
105 " When editing a file, always jump to the last known cursor position.
106 " Don't do it when the position is invalid or when inside an event handler
107 " (happens when dropping a file on gvim).
108 autocmd BufReadPost *
109 \ if line("'\"") > 0 && line("'\"") <= line("$") |
110 \ exe "normal! g`\"" |
117 set autoindent " always set autoindenting on
119 endif " has("autocmd")
121 " Convenient command to see the difference between the current buffer and the
122 " file it was loaded from, thus the changes you made.
123 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
124 \ | wincmd p | diffthis
130 let line_no = line(".")
131 let last_indent = indent(line_no - 1)
132 let this_indent = indent(line_no)
133 let line = getline(line_no)
134 let last_line = getline(line_no - 1)
135 let line_spaces = substitute(line, "\t", " ", "g")
136 let length = strlen(line_spaces)
137 let line_stripped = line_spaces[this_indent : length]
138 let no_tabs = strlen(substitute(last_line, "[^\t]", "", "g"))
139 let no_spaces = this_indent - no_tabs * 2
140 call setline(".", (repeat("\t" , no_tabs) . repeat(" ", no_spaces) . line_stripped))
142 nmap =c == :call FixIndent()<CR>