changed some vi settings that I got from default tip
authorYi Qiang <yqiang@gmail.com>
Wed Nov 12 15:18:10 2008 -0800 (8 weeks ago)
changeset 540d98925dbe99
parent 531d77ed11867d
changed some vi settings that I got from
http://items.sjbach.com/319/configuring-vim-right
--- a/vimrc Wed Nov 12 08:46:19 2008 -0800
+++ b/vimrc Wed Nov 12 15:18:10 2008 -0800
@@ -1,13 +1,14 @@
" Don't load plugins if we aren't in Vim7
if version < 700
- set noloadplugins
+ set noloadplugins
endif
"" Skip this file unless we have +eval
if 1
""" Settings
-set nocompatible " Don't be compatible with vi
+set nocompatible " Don't be compatible with vi
+set hidden " The current buffer can be put to the background without writing to disk; When a background buffer becomes current again, marks and undo-history are remembered.
"""" Movement
" work more logically with wrapped lines
@@ -15,61 +16,62 @@ noremap k gk
noremap k gk
"""" Searching and Patterns
-set ignorecase " search is case insensitive
-set smartcase " search case sensitive if caps on
-set incsearch " show best match so far
-set nohlsearch " Do not highlight search results
+set ignorecase " search is case insensitive
+set smartcase " search case sensitive if caps on
+set incsearch " show best match so far
+set nohlsearch " Do not highlight search results
"""" Display
-set background=dark " I use dark background
-set lazyredraw " Don't repaint when scripts are running
-set scrolloff=3 " Keep 3 lines below and above the cursor
-set ruler " line numbers and column the cursor is on
-set number " Show line numbering
-set numberwidth=1 " Use 1 col + 1 space for numbers
-colorscheme desert " default colorscheme for terminals
-
+set background=dark " I use dark background
+set lazyredraw " Don't repaint when scripts are running
+set scrolloff=3 " Keep 3 lines below and above the cursor
+set ruler " line numbers and column the cursor is on
+set number " Show line numbering
+set numberwidth=1 " Use 1 col + 1 space for numbers
+colorscheme desert " default colorscheme for terminals
+set title " sets the terminal title
+set scrolloff=3 " start the scrolling three lines before the border, keeping more context around where you’re working.
""" Mouse
-set mousemodel=popup_setpos " Right mouse button extends a selection
-"set mousefocus " Focus follows mouse
+set mousemodel=popup_setpos " Right mouse button extends a selection
+"set mousefocus " Focus follows mouse
""" Windows
-if exists(":tab") " Try to move to other windows if changing buf
- set switchbuf=useopen,usetab
-else " Try other windows & tabs if available
- set switchbuf=useopen
+if exists(":tab") " Try to move to other windows if changing buf
+ set switchbuf=useopen,usetab
+else " Try other windows & tabs if available
+ set switchbuf=useopen
endif
"""" Messages, Info, Status
-set shortmess+=a " Use [+] [RO] [w] for modified, read-only, modified
-set showcmd " Display what command is waiting for an operator
-set ruler " Show pos below the win if there's no status line
-set laststatus=2 " Always show statusline, even if only 1 window
-set report=0 " Notify me whenever any lines have changed
-set confirm " Y-N-C prompt if closing with unsaved changes
-set vb t_vb= " Disable visual bell! I hate that flashing.
+set shortmess+=a " Use [+] [RO] [w] for modified, read-only, modified
+set showcmd " Display what command is waiting for an operator
+set ruler " Show pos below the win if there's no status line
+set laststatus=2 " Always show statusline, even if only 1 window
+set report=0 " Notify me whenever any lines have changed
+set confirm " Y-N-C prompt if closing with unsaved changes
+set vb t_vb= " Disable visual bell! I hate that flashing.
"""" Editing
-set backspace=2 " Backspace over anything! (Super backspace!)
-set showmatch " Briefly jump to the previous matching paren
-set matchtime=2 " For .2 seconds
-set formatoptions+=tcrqon " auto-wrap text, comments
+set backspace=2 " Backspace over anything! (Super backspace!)
+set showmatch " Briefly jump to the previous matching paren
+set matchtime=2 " For .2 seconds
+set formatoptions+=tcrqon " auto-wrap text, comments
set autoindent " copy indent from current line when starting a new line
set smartindent " do smart indenting as well
-set tabstop=4 " Tab stop of 4
-set shiftwidth=4 " sw 4 spaces (used on auto indent)
-set softtabstop=4 " 4 spaces as a tab for bs/del
+set tabstop=4 " Tab stop of 4
+set shiftwidth=4 " sw 4 spaces (used on auto indent)
+set softtabstop=4 " 4 spaces as a tab for bs/del
set smarttab " tab in front of a line inserts blanks
-set autowriteall " Automatically write to disk
-set smarttab " super smart tabs
-set textwidth=78 " keep to 78 chars per line
+set autowriteall " Automatically write to disk
+set smarttab " super smart tabs
+set textwidth=78 " keep to 78 chars per line
" we don't want to edit these type of files
set wildignore=*.o,*.obj,*.bak,*.exe,*.pyc,*.swp
"""" Coding
-set history=100 " 100 Lines of history
-set showfulltag " Show more information while completing tags
+set history=100 " 100 Lines of history
+set showfulltag " Show more information while completing tags
filetype plugin on " Enable filetype plugins
filetype plugin indent on " Let filetype plugins indent for me
syntax on " Turn on syntax highlighting
@@ -79,53 +81,54 @@ set tags+=$HOME/.vim/tags/python.ctags
set tags+=$HOME/.vim/tags/python.ctags
""""" Folding
-set foldmethod=syntax " By default, use syntax to determine folds
-set foldlevelstart=99 " All folds open by default
-set foldcolumn=0 " Don't show the fold column by default
+set foldmethod=syntax " By default, use syntax to determine folds
+set foldlevelstart=99 " All folds open by default
+set foldcolumn=0 " Don't show the fold column by default
"""" Command Line
set wildmenu " Autocomplete features in the status bar
+set wildmode=list:longest
"""" Autocommands
if has("autocmd")
augroup vimrcEx
au!
- " In plain-text files and svn commit buffers, wrap automatically at 78 chars
- au FileType text,svn setlocal tw=78 fo+=t
+ " In plain-text files and svn commit buffers, wrap automatically at 78 chars
+ au FileType text,svn setlocal tw=78 fo+=t
- " In all files, try to jump back to the last spot cursor was in before exiting
- au BufReadPost *
- \ if line("'\"") > 0 && line("'\"") <= line("$") |
- \ exe "normal g`\"" |
- \ endif
+ " In all files, try to jump back to the last spot cursor was in before exiting
+ au BufReadPost *
+ \ if line("'\"") > 0 && line("'\"") <= line("$") |
+ \ exe "normal g`\"" |
+ \ endif
- " Use :make to check a script with perl
- au FileType perl set makeprg=perl\ -c\ %\ $* errorformat=%f:%l:%m
+ " Use :make to check a script with perl
+ au FileType perl set makeprg=perl\ -c\ %\ $* errorformat=%f:%l:%m
- " Use :make to compile c, even without a makefile
- au FileType c,cpp if glob('Makefile') == "" | let &mp="gcc -o %< %" | endif
+ " Use :make to compile c, even without a makefile
+ au FileType c,cpp if glob('Makefile') == "" | let &mp="gcc -o %< %" | endif
- " Switch to the directory of the current file, unless it's a help file.
- au BufEnter * if &ft != 'help' | silent! cd %:p:h | endif
+ " Switch to the directory of the current file, unless it's a help file.
+ au BufEnter * if &ft != 'help' | silent! cd %:p:h | endif
- " Insert Vim-version as X-Editor in mail headers
- au FileType mail sil 1 | call search("^$")
- \ | sil put! ='X-Editor: Vim-' . Version()
+ " Insert Vim-version as X-Editor in mail headers
+ au FileType mail sil 1 | call search("^$")
+ \ | sil put! ='X-Editor: Vim-' . Version()
- " smart indenting for python
- au FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
+ " smart indenting for python
+ au FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
- " allows us to run :make and get syntax errors for our python scripts
- au FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
- " setup file type for code snippets
- "au FileType python if &ft !~ 'django' | setlocal filetype=python.django_template.django_model | endif
- au FileType python set expandtab
+ " allows us to run :make and get syntax errors for our python scripts
+ au FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
+ " setup file type for code snippets
+ "au FileType python if &ft !~ 'django' | setlocal filetype=python.django_template.django_model | endif
+ au FileType python set expandtab
- " kill calltip window if we move cursor or leave insert mode
- au CursorMovedI * if pumvisible() == 0|pclose|endif
- au InsertLeave * if pumvisible() == 0|pclose|endif
+ " kill calltip window if we move cursor or leave insert mode
+ au CursorMovedI * if pumvisible() == 0|pclose|endif
+ au InsertLeave * if pumvisible() == 0|pclose|endif
- augroup END
+ augroup END
endif
@@ -160,6 +163,12 @@ nnoremap p p=`]
nnoremap p p=`]
nnoremap <c-p> p
+"The leader character is your own personal modifier key, as g is Vim’s modifier key (when compared to vi).
+let mapleader = "<SPACE>"
+
+" Typing 'a will jump to the line in the current file marked with ma. However, `a will jump to the line and column marked with ma.
+nnoremap ' `
+nnoremap ` '
" Map switching buffers
map <C-right> <ESC>:bn<CR>
@@ -191,10 +200,10 @@ map <D-9> 9gt<cr>
map <D-9> 9gt<cr>
" bind ctrl+space for omnicompletion
inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
- \ "\<lt>C-n>" :
- \ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
- \ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
- \ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
+ \ "\<lt>C-n>" :
+ \ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
+ \ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
+ \ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
imap <C-@> <C-Space>
" Toggle the tag list bar