When vim is run by default it will look for a vimrc file that contains configuration info and scripts that it can use while it is running. The file can also be found here.
"
" .vimrc
"
" Vim configuration resource file. Specifies desired
" behavior for the vim editor.
"
:set showmode " Tell you if you're in insert mode
:set tabstop=4 " Set the tabstop to 4 spaces
:set shiftwidth=4 " Shiftwidth should match tabstop
:set expandtab " Convert tabs to
:set nowrap " Do not wrap lines longer than the window
:set wrapscan " Wrap to the top of the file while searching
:set ruler " Show the cursor position all the time
:set showmatch " Show matching [] () {} etc...
:set smartindent " Let vim help you with your code indention
:set formatoptions+=ro " Automatically insert the comment character when
" you hit
:set backspace=2 " makes backspace work like you expect
:set nohlsearch " Don't highlight strings you're searching for
:set incsearch " Do highlight as you type your search
:set ignorecase " makes searches case-insensitive
" Disable paren highlighting
"let loaded_matchparen = 1
" Switch syntax highlighting on, when the terminal can support colors
" if # of terminal colors > 2 OR you're using Gvim
if &t_Co > 2 has("gui_running")
:syntax on
" Change the highlight color for Comment and Special
" to Cyan. Blue is too dark for a black background.
:highlight Comment term=bold ctermfg=cyan guifg=cyan
:highlight Special term=bold ctermfg=cyan guifg=cyan
:highlight Constant term=bold ctermfg=red guifg=cyan
endif
" Make vim turn *off* expandtab for files named Makefile or makefile
" We need the tab literal
:autocmd BufNewFile,BufRead [Mm]akefile* set noexpandtab
" Make vim recognize a file ending in ".template" be a C++ source file
:autocmd BufNewFile,BufRead *.template set ft=cpp
" Make vim tab 2 spaces for HTML files
:autocmd BufNewFile,BufRead *.htm* set tabstop=2
:autocmd BufNewFile,BufRead *.htm* set shiftwidth=2
" Make vin tab 2 spaces for PHP files
:autocmd BufNewFile,BufRead *.php set tabstop=2
:autocmd BufNewFile,BufRead *.php set shiftwidth=2
" Make vim recognize Y86 assembly files
:autocmd BufNewFile,BufRead *.ys set ft=asm
:autocmd BufNewFile,BufRead *.ys set nosmartindent
" Make vim recognize R files
:autocmd BufNewFile,BufRead *.[Rr] set ft=r
" Make vim recognize Prolog files
:autocmd BufNewFile,BufRead *.pl set ft=prolog
" Turn off paren matching for Prolog files
:autocmd BufNewFile,BufRead *.pl NoMatchParen
" Adds main program heading from Program Style Guidelines
function FileHeading()
let s:line=line(".")
call setline( s:line,"// Program: ")
call append( s:line,"// Author: Derrick")
call append(s:line+1,"// Date: ".strftime("%b %d %Y"))
call append(s:line+2,"// Assignment: ")
call append(s:line+3,"// Purpose: ")
call append(s:line+4,"// ")
call append(s:line+5,"// Input: ")
call append(s:line+6,"// Output: ")
call append(s:line+7,"// Related")
call append(s:line+8,"// Files: ")
call append(s:line+9,"// Functions: ")
call append(s:line+10,"// ")
call append(s:line+11,"")
unlet s:line
endfunction
" Adds class heading from Program Style Guidelines
function ClassHeading()
let s:line=line(".")
call setline( s:line,"// Program Name: ")
call append( s:line,"// Author: Derrick")
call append(s:line+1,"// Date: ".strftime("%b %d %Y"))
call append(s:line+2,"// Assignment: ")
call append(s:line+3,"// Purpose: ")
call append(s:line+4,"// ")
call append(s:line+5,"// Public class variables")
call append(s:line+6,"// ")
call append(s:line+7,"// Public functions:")
call append(s:line+8,"// ")
call append(s:line+9,"// Related files:")
call append(s:line+10,"// ")
call append(s:line+11,"")
unlet s:line
endfunction
" Adds function heading from Program Style Guidelines
function FunctionHeading()
let s:line=line(".")
call setline( s:line,"//****************************************************************************")
call append( s:line,"// Function name: ")
call append(s:line+1,"// Author: Derrick")
call append(s:line+2,"// Date: ".strftime("%b %d %Y"))
call append(s:line+3,"// Purpose: ")
call append(s:line+4,"// Params: ")
call append(s:line+5,"// ")
call append(s:line+6,"// Returns: ")
call append(s:line+7,"//****************************************************************************")
unlet s:line
endfunction
" Adds HTML skeleton to file
function HTMLFrame()
let s:line=line(".")
call setline( s:line,"")
call append( s:line," ")
call append(s:line+1," ")
call append(s:line+2," ")
call append(s:line+3," ")
call append(s:line+4," ")
call append(s:line+5," ")
call append(s:line+6,"")
unlet s:line
endfunction
" Adds Unix shebang line to beginning of
" any new Ruby script
function RubyFile()
let s:line=line(".")
call setline( s:line,"#!/usr/bin/env ruby")
call append( s:line,"")
unlet s:line
endfunction
" If opening new file with these file extentions
" then execute corresponding functions
:autocmd BufNewFile *.C,*.c execute FileHeading()
:autocmd BufNewFile *.h execute ClassHeading()
:autocmd BufNewFile *.htm* execute HTMLFrame()
:autocmd BufNewFile *.php execute HTMLFrame()
:autocmd BufNewFile *.rb execute RubyFile()
" Map keys to perform series of key strokes and functions
" Ex, If F2 is pressed then execute FileHeading function,
" and move cursor to first line of comments
imap
imap
imap
没有评论:
发表评论