分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
VIM配置文件vimrc
Ubuntu 默认情况下只安装tiny-vim , 只要运行 sudo apt-get install vim 安装完整的vim就好了
.vimrc 下载
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Author: sunboy_2050" Version: 1.0" Last Change: 2011-11-11 11:11:11" http://blog.csdn.net/sunboy_2050"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" General""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Get out of VI's compatible mode..set nocompatible" Platformfunction! MySys() return "linux"endfunction"Sets how many lines of history VIM har to rememberset history=400" Chineseif MySys() == "windows" "set encoding=utf-8 "set langmenu=zh_CN.UTF-8 "language message zh_CN.UTF-8 "set fileencodings=ucs-bom,utf-8,gb18030,cp936,big5,euc-jp,euc-kr,latin1endif"Enable filetype pluginfiletype plugin onfiletype indent on"Set to auto read when a file is changed from the outsideset autoread"Have the mouse enabled all the time:set mouse=a"Set mapleaderlet mapleader = ","let g:mapleader = ",""Fast savingnmap ww :wnmap wf :w!" Fast quitingnmap qw :wqnmap qf :q!nmap qq :qnmap qa :qa"Fast remove highlight searchnmap :noh" Fast redrawnmap rr :redraw!" Switch to buffer according to file namefunction! SwitchToBuf(filename) "let fullfn = substitute(a:filename, "^\\~/", $HOME . "/", "") " find in current tab let bufwinnr = bufwinnr(a:filename) if bufwinnr != -1 exec bufwinnr . "wincmd w" return else " find in each tab tabfirst let tab = 1 while tab <= tabpagenr("{1}quot;) let bufwinnr = bufwinnr(a:filename) if bufwinnr != -1 exec "normal " . tab . "gt" exec bufwinnr . "wincmd w" return endif tabnext let tab = tab + 1 endwhile " not exist, new tab exec "tabnew " . a:filename endifendfunction"Fast edit vimrcif MySys() == 'linux' "Fast reloading of the .vimrc map ss :source ~/.vimrc "Fast editing of .vimrc map ee :call SwitchToBuf(" ~/.vimrc") " When .vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrcelseif MySys() == 'windows' " Set helplang set helplang=cn "Fast reloading of the _vimrc map ss :source ~/_vimrc "Fast editing of _vimrc map ee :call SwitchToBuf(" ~/_vimrc") " When _vimrc is edited, reload it autocmd! bufwritepost _vimrc source ~/_vimrc "Fast copying from linux func! CopyFromZ() autocmd! bufwritepost _vimrc exec 'split y:/.vimrc' exec 'normal 17G' exec 's/return "linux"/return "windows"/' exec 'w! ~/_vimrc' exec 'normal u' exec 'q' endfunc nnoremap uu :call CopyFromZ():so ~/_vimrcendif" For windows versionif MySys() == 'windows' source $VIMRUNTIME/mswin.vim behave mswin set diffexpr=MyDiff() function! MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let eq = '' if $VIMRUNTIME =~ ' ' if &sh =~ '\ let cmd = '""' . $VIMRUNTIME . '\diff"' let eq = '"' else let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' endif else let cmd = $VIMRUNTIME . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq endfunctionendif"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Colors and Fonts""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Set font"if MySys() == "linux"" set gfn=Monospace\ 11"endif" Avoid clearing hilight definition in pluginsif !exists("g:vimrc_loaded") "Enable syntax hl syntax enable " color scheme if has("gui_running") set guioptions-=T set guioptions-=m set guioptions-=L set guioptions-=r colorscheme darkblue_my "hi normal guibg=#294d4a else "colorscheme desert_my" endif " hasendif " exists(...)"Some nice mapping to switch syntax (useful if one mixes different languages in one file)map 1 :set syntax=cmap 2 :set syntax=xhtmlmap 3 :set syntax=pythonmap 4 :set ft=javascriptmap $ :syntax sync fromstartautocmd BufEnter * :syntax sync fromstart" Highlight current"if has("gui_running")" set cursorline" hi cursorline guibg=#333333" hi CursorColumn guibg=#333333"endif"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Fileformats""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Favorite filetypesset ffs=unix,dosnmap fd :se ff=dosnmap fu :se ff=unix" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" VIM userinterface""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Set 7 lines to the curors - when moving vertical.."set so=7" Maximum window when GUI runningif has("gui_running") set lines=9999 set columns=9999endif"Turn on WiLd menuset wildmenu"Always show current positionset ruler"The commandbar is 2 highset cmdheight=2"Show line numberset nu"Do not redraw, when running macros.. lazyredrawset lz"Change buffer - without saving"set hid"Set backspaceset backspace=eol,start,indent"Bbackspace and cursor keys wrap to"set whichwrap+=<,>,h,lset whichwrap+=<,>"Ignore case when searching"set ignorecase"Include searchset incsearch"Highlight search thingsset hlsearch"Set magic onset magic"No sound on errors.set noerrorbellsset novisualbellset t_vb="show matching bracets"set showmatch"How many tenths of a second to blink"set mat=2 """""""""""""""""""""""""""""" " Statusline """""""""""""""""""""""""""""" "Always hide the statusline set laststatus=2 function! CurDir() let curdir = substitute(getcwd(), '/home/easwy/', "~/", "g") return curdir endfunction "Format the statusline "set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c""""""""""""""""""""""""""""""" Visual""""""""""""""""""""""""""""""" From an idea by Michael Naumannfunction! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n{1}quot;, "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" else execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_regendfunction"Basically you press * or # to search for the current selection !! Really usefulvnoremap * :call VisualSearch('f')vnoremap # :call VisualSearch('b')""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Moving around and tabs""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Map space to / and c-space to ?"map /"map ?" Smart way to move btw. windowsnmap jnmap knmap hnmap l"Actually, the tab does not switch buffers, but my arrows"Bclose function can be found in "Buffer related" sectionmap bd :Bclose"map bd" Use the arrows to something usefull"map :bn" map :bp"Tab configurationmap tn :tabnewmap te :tabeditmap tc :tabclosemap tm :tabmovetry set switchbuf=useopen set stal=1catchendtry" Moving fast to front, back and 2 sides ;)imap 1 }gt; $aimap -0> 0i"Switch to current dirmap cd :cd %:p:h" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Parenthesis/bracket expanding""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""vnoremap @1 `>a)`")vnoremap @2 `>a]`vnoremap @3 `>a}`vnoremap @$ `>a"`vnoremap @q `>a'`vnoremap @w `>a"`"Map auto complete of (, ", ', [inoremap @1 ():let leavechar=")"iinoremap @2 []:let leavechar="]"iinoremap @3 {}:let leavechar="}"iinoremap @4 {o}:let leavechar="}"Oinoremap @q '':let leavechar="'"iinoremap @w "":let leavechar='"'i"au BufNewFile,BufRead *.\(vim\)\@! inoremap " "":let leavechar='"'i"au BufNewFile,BufRead *.\(txt\)\@! inoremap ' '':let leavechar="'"i"imap :exec "normal f" . leavechara"imap :exec "normal f" . leavechara""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" General Abbrevs""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""My informationiab xdate =strftime(" %c")iab xname Easwy Yang" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Editing mappings etc."""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge nohl exe "normal `z"endfunc" do not automaticlly remove trailing whitespace"autocmd BufWrite *.[ch] :call DeleteTrailingWS()"autocmd BufWrite *.cc :call DeleteTrailingWS()"autocmd BufWrite *.txt :call DeleteTrailingWS()nmap ws :call DeleteTrailingWS():w"nmap ws! :call DeleteTrailingWS():w!" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Command-line config""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Bash likecnoremap cnoremap cnoremap " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Buffer realted""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Open a dummy buffer for pastemap es :tabnew:setl buftype=nofileif MySys() == " linux"map ec :tabnew ~/tmp/scratch.txtelsemap ec :tabnew $TEMP/scratch.txtendif" Restore cursor to file position in previous editing sessionset viminfo='10,\"100,:20,n~/.viminfoau BufReadPost * if line("'\"") > 0|if line("'\"") <= line("{1}quot;)|exe("norm '\"")|else|exe "norm {1}quot;|endif|endif" Don't close window, when deleting a buffercommand! Bclose call BufcloseCloseIt()function! BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endifendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Session options"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set sessionoptions-=curdirset sessionoptions+=sesdir"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Files and backups""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Turn backup offset nobackupset nowb"set noswapfile"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Folding""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Enable folding, I find it very useful"set fen"set fdl=0nmap zo zOvmap zo zO" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Text options"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set expandtabset shiftwidth=4map t2 :set shiftwidth=2map t4 :set shiftwidth=4au FileType html,python,vim,javascript setl shiftwidth=2"au FileType html,python,vim,javascript setl tabstop=2au FileType java,c setl shiftwidth=4"au FileType java setl tabstop=4au FileType txt setl lbrau FileType txt setl tw=78set smarttab"set lbr"set tw=78 """""""""""""""""""""""""""""" " Indent """""""""""""""""""""""""""""" "Auto indent set ai "Smart indet set si "C-style indeting set cindent "Wrap lines set wrap"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Spell checking"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""map sn ]smap sp [smap sa zgmap s? z="""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Complete"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" optionsset completeopt=menuset complete-=uset complete-=i" mappinginoremap pumvisible()?"\" :"\" inoremap pumvisible()?"\\\" :"\" inoremap pumvisible()?"\\\" :"\" inoremap pumvisible()?"\" :"\" inoremap inoremap inoremap inoremap " Enable syntaxif has("autocmd") && exists("+omnifunc") autocmd Filetype * \if &omnifunc == "" | \ setlocal omnifunc=syntaxcomplete#Complete | \endifendif"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" cscope setting"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""if has("cscope") if MySys() == "linux" set csprg=/usr/bin/cscope else set csprg=cscope endif set csto=1 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out endif set csverbendifnmap s :cs find s =expand(" ")nmap g :cs find g =expand(" ")nmap c :cs find c =expand(" ")nmap t :cs find t =expand(" ")nmap e :cs find e =expand(" ")nmap f :cs find f =expand(" ")nmap i :cs find i ^=expand(" "){1}lt;CR>nmap d :cs find d =expand(" ")" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Plugin configuration""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""" " Super Tab """""""""""""""""""""""""""""" "let g:SuperTabDefaultCompletionType = "" let g:SuperTabDefaultCompletionType = "" """ """"""""""""""""""""""""""" " yank ring setting """""""""""""""""""""""""""""" map yr :YRShow """ """"""""""""""""""""""""""" " file explorer setting """""""""""""""""""""""""""""" "Split vertically let g:explVertical=1 "Window size let g:explWinSize=35 let g:explSplitLeft=1 let g:explSplitBelow=1 "Hide some files let g:explHideFiles='^\.,.*\.class$,.*\.swp$,.*\.pyc$,.*\.swo$,\.DS_Store
"Hide the help thing.. let g:explDetailedHelp=0 """""""""""""""""""""""""""""" " minibuffer setting """""""""""""""""""""""""""""" let loaded_minibufexplorer = 1 " *** Disable minibuffer plugin let g:miniBufExplorerMoreThanOne = 2 " Display when more than 2 buffers let g:miniBufExplSplitToEdge = 1 " Always at top let g:miniBufExplMaxSize = 3 " The max height is 3 lines let g:miniBufExplMapWindowNavVim = 1 " map CTRL-[hjkl] let g:miniBufExplUseSingleClick = 1 " select by single click let g:miniBufExplModSelTarget = 1 " Dont change to unmodified buffer let g:miniBufExplForceSyntaxEnable = 1 " force syntax on "let g:miniBufExplVSplit = 25 "let g:miniBufExplSplitBelow = 0 autocmd BufRead,BufNew :call UMiniBufExplorer """""""""""""""""""""""""""""" " bufexplorer setting """""""""""""""""""""""""""""" let g:bufExplorerDefaultHelp=1 " Do not show default help. let g:bufExplorerShowRelativePath=1 " Show relative paths. let g:bufExplorerSortBy='mru' " Sort by most recently used. let g:bufExplorerSplitRight=0 " Split left. let g:bufExplorerSplitVertical=1 " Split vertically. let g:bufExplorerSplitVertSize = 30 " Split width let g:bufExplorerUseCurrentWindow=1 " Open in new window. let g:bufExplorerMaxHeight=13 " Max height """""""""""""""""""""""""""""" " taglist setting """""""""""""""""""""""""""""" if MySys() == "windows" let Tlist_Ctags_Cmd = 'ctags' elseif MySys() == "linux" let Tlist_Ctags_Cmd = '/usr/bin/ctags' endif let Tlist_Show_One_File = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_Right_Window = 1 nmap tl :Tlist """ """"""""""""""""""""""""""" " winmanager setting """""""""""""""""""""""""""""" let g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList" let g:winManagerWidth = 30 let g:defaultExplorer = 0 nmap :FirstExplorerWindow nmap :BottomExplorerWindow nmap wm :WMToggle autocmd BufWinEnter \[Buf\ List\] setl nonumber """ """"""""""""""""""""""""""" " netrw setting """""""""""""""""""""""""""""" let g:netrw_winsize = 30 nmap fe :Sexplore! """ """"""""""""""""""""""""""" " LaTeX Suite things """""""""""""""""""""""""""""" set grepprg=grep\ -nH\ $* let g:Tex_DefaultTargetFormat="pdf" let g:Tex_ViewRule_pdf='xpdf' "Bindings autocmd FileType tex map :w! :silent! call Tex_RunLaTeX() "Auto complete some things ;) autocmd FileType tex inoremap $i \indent autocmd FileType tex inoremap $* \cdot autocmd FileType tex inoremap $i \item autocmd FileType tex inoremap $m \[\]O """ """"""""""""""""""""""""""" " lookupfile setting """""""""""""""""""""""""""""" let g:LookupFile_MinPatLength = 2 let g:LookupFile_PreserveLastPattern = 0 let g:LookupFile_PreservePatternHistory = 0 let g:LookupFile_AlwaysAcceptFirst = 1 let g:LookupFile_AllowNewFiles = 0 if filereadable("./filenametags") let g:LookupFile_TagExpr = '"./filenametags"' endif nmap lk LookupFile nmap ll :LUBufs nmap lw :LUWalk " lookup file with ignore case function! LookupFile_IgnoreCaseFunc(pattern) let _tags = &tags try let &tags = eval(g:LookupFile_TagExpr) let newpattern = '\c' . a:pattern let tags = taglist(newpattern) catch echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE return "" finally let &tags = _tags endtry " Show the matches for what is typed so far. let files = map(tags, 'v:val["filename"]') return files endfunction let g:LookupFile_LookupFunc = 'LookupFile_IgnoreCaseFunc' """ """"""""""""""""""""""""""" " markbrowser setting """""""""""""""""""""""""""""" nmap mk :MarksBrowser """ """"""""""""""""""""""""""" " showmarks setting """""""""""""""""""""""""""""" " Enable ShowMarks let showmarks_enable = 1 " Show which marks let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" " Ignore help, quickfix, non-modifiable buffers let showmarks_ignore_type = "hqm" " Hilight lower & upper marks let showmarks_hlline_lower = 1 let showmarks_hlline_upper = 1 """""""""""""""""""""""""""""" " mark setting """""""""""""""""""""""""""""" nmap hl MarkSet vmap hl MarkSet nmap hh MarkClear vmap hh MarkClear nmap hr MarkRegex vmap hr MarkRegex """ """"""""""""""""""""""""""" " FeralToggleCommentify setting """""""""""""""""""""""""""""" let loaded_feraltogglecommentify = 1 "map tc :call ToggleCommentify()j "imap :call ToggleCommentify()j """ """"""""""""""""""""""""""" " vimgdb setting """""""""""""""""""""""""""""" let g:vimgdb_debug_file = "" run macros/gdb_mappings.vim"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Filetype generic""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Todo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "au BufNewFile,BufRead *.todo so ~/vim_local/syntax/amido.vim """""""""""""""""""""""""""""" " HTML related """""""""""""""""""""""""""""" " HTML entities - used by xml edit plugin let xml_use_xhtml = 1 "let xml_no_auto_nesting = 1 "To HTML let html_use_css = 1 let html_number_lines = 0 let use_xhtml = 1 """"""""""""""""""""""""""""""" " Vim section """"""""""""""""""""""""""""""" autocmd FileType vim set nofen autocmd FileType vim map :w!:source % """ """"""""""""""""""""""""""" " HTML """"""""""""""""""""""""""""""" au FileType html set ft=xml au FileType html set syntax=html """""""""""""""""""""""""""""" " C/C++ """"""""""""""""""""""""""""""" autocmd FileType c,cpp map :make "autocmd FileType c,cpp setl foldmethod=syntax | setl fen""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" MISC""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Quickfix nmap cn :cn nmap cp :cp nmap cw :cw 10 " nmap cc :botright lw 10 "map :q:botright cw 10 function! s:GetVisualSelection() let save_a = @a silent normal! gv" ay let v = @a let @a = save_a let var = escape(v, '\\/.$*') return var endfunction " Fast grep nmap lv :lv /=expand(" ")/ %:lw vmap lv :lv /=GetVisualSelection()/ %:lw " Fast diff cmap @vd vertical diffsplit set diffopt+=vertical "Remove the Windows ^M noremap dm mmHmn:%s///ge'nzt'm " Paste toggle - when pasting something in, don't indent. set pastetoggle= "Remove indenting on empty lines "map :%s/\s*$//g:noh' ' "Super paste "inoremap :set pastemui+mv' uV'v=:set nopaste "Fast Ex command nnoremap ; : "For mark move nnoremap ' ' "Fast copy nnoremap ' " "A function that inserts links & anchors on a TOhtml export. " Notice: " Syntax used is: " Link " Anchor function! SmartTOHtml() TOhtml try %s/"\s\+\*> \(.\+\)" #\1" style="color: cyan">\1<\/a> %s/"\(-\|\s\)\+\*> \(.\+\)" \ \ #\2" style="color: cyan;">\2<\/a> %s/"\s\+=> \(.\+\)" 1" style="color: #fff">\1<\/a> catch endtry exe ":write!" exe ":bd" endfunction""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Mark as loaded""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""let g:vimrc_loaded = 1
===========================================================================
vimrc配置文件详解
"set encoding=chinese
"set langmenu=zh_CN.UTF-8"
if version >= 603
set helplang=cn
endif
set langmenu=zh_CN.UTF-8
"set imcmdline "这一句导致字体大小、颜色设置失效
"set guifont=Monospace/ 12
set guifont=DejaVu/ Sans/ Mono/ 12
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"下一行为语法高亮,彩色的
syntax on
"添加自动缩进
set tabstop=4
set shiftwidth=4
set softtabstop=4
set ai "开启自动缩进
"set expandtab "自动把tab转化为空格
"retab "将已存在的tab都转化为空格
set list "显示tab和行尾空格
set lcs=tab:+-,trail:- "显示tab为+---和行尾空格(只在输入时才显示)
"折叠python代码
"set foldmethod=indent
"let Tlist_Auto_Open=1 "auto open taglist自动打开taglist
set autoindent "自动缩进?
"添加python字典,实现自动补全(字典目录为~/.vim/pydiction,里面有字典和一个脚本),快捷键:ctrl+n(20080320 ~/.vim/tools/也可以)
if has("autocmd")
autocmd FileType python set complete+=k~/.vim/tools/pydiction
endif
"安F8智能补全
inoremap
map
set nobackup "不自动备份
set nu "开启行号
"搜索字高亮
set hlsearch
"取消 Vim 对 HTML 标记自动产生的缩进,但打开自动缩进选项
au FileType html setlocal autoindent indentexpr=
" multi-encoding setting
if has("multi_byte")
"set bomb
set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1
" CJK environment detection and corresponding setting
if v:lang =~ "^zh_CN"
" Use cp936 to support GBK, euc-cn == gb2312
set encoding=cp936
set termencoding=cp936
set fileencoding=cp936
elseif v:lang =~ "^zh_TW"
" cp950, big5 or euc-tw
" Are they equal to each other?
set encoding=big5
set termencoding=big5
set fileencoding=big5
elseif v:lang =~ "^ko"
" Copied from someone's dotfile, untested
set encoding=euc-kr
set termencoding=euc-kr
set fileencoding=euc-kr
elseif v:lang =~ "^ja_JP"
" Copied from someone's dotfile, untested
set encoding=euc-jp
set termencoding=euc-jp
set fileencoding=euc-jp
endif
" Detect UTF-8 locale, and replace CJK setting if needed
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif
*************************************
//////////////////////////////////////////
1.tabstop (ts-数值型): 设定文件中制表位占的空格个数,默认是8
:set ts=4 (表示一个插入一个
2.expandtab (et-布尔型): 插入
:set ts=10 et (此时插入一个tab时,真正插入的是10个空格)
注: 当'et'打开,要插入实际的制表位,需用CTRL-V
3.softtabstop (sts-数值型): 当插入一个
而当'ts'值小于'sts',则此时就插入几个制表位(制表位的个数是'sts'整除'ts'之商)
和几个空格(空格的个数是'sts'整除'ts'之余数),默认是0,表示关闭
:set ts=8 sts=6 (此时插入一个
在此设置下这样输入: 一个
:set ts=3 sts=8 (此时插入一个
4.retab (ret-ex下的命令,前面3个是选项): 把制表位和空格组成的连续序列替换成新的制表位或空格
格式是 :[range]ret[!] [ts值] (不是指定range,默认是全文;不指定'ts'值,就用原来的'ts'值)
(1) 当'et'为关闭状态时,retab会尽量把由"制表位和空格组成的连续空白序列"替换成尽可能多的制表位,如:
有一个连续"空白序列"是由: 3个空格,两个制表位,5个空格组成,这时设置如下命令
:ret 6 (原来的"空白序列"变为由: 3个制表位,2个空格组成的新的"空白序列")
(2) 当'et'为开启状态时,retab会把所有的制表位换成当前'ts
(3) :ret! 命令则会把纯粹由空格组成的"空白序列"强制替换为尽可能多的制表位加空格
注:retab命令对文本的处理,不会引起视觉上的变化
5.smarttab (sta-布尔型): 它确定行首插入
:set sta (则若行首插入一个
而这里的"空白序列"是由什么组成,是由'sw','ts'值的相对大小,以及是否开启了'et'决定的.
若'sw'小于'ts'的值,且'et'是关闭的,则行首插入一个
若'sw'大于'ts'的值,且'et'是关闭的,则行首插入一个
若'et'是开启的,若行首插入一个
注:选项'sw'只用于normal下的左右移动命令: > , >> , < , <<
************************ 说 明 *********************************
*
* (a) 文中的
* 而文中的"制表位"表示前面那个动作后的输入;
* (b) 为了便于制表位和空格的区分,也就是让它们成为"可见"模式:
* :set list
* :set lcs=eol:&,tab<+
set list "显示tab和行尾空格
set lcs=tab:>-,trail:- "显示tab为---和行尾空格(只在输入时才显示)
* 这样每行结尾有字符"&",制表位若是4,则为:<+++ ,
* 而若制表位是8,则为:<+++++++
* (c)
* 但象normal下"x"这样的命令就只能删除真正的制表位和空格
==========================================================================
20090123
" 自动补全命令时候使用菜单式匹配列表
set wildmenu
" 允许退格键删除
set backspace=2
" 启用鼠标
set mouse=a
" 文件类型
filetype on
filetype plugin on
filetype indent on
" 设置编码自动识别, 中文引号显示
"set fileencodings=utf-8,cp936,big5,euc-jp,euc-kr,latin1,ucs-bom
set fileencodings=utf-8,gbk,ucs-bom
set ambiwidth=double
" 移动长行
nnoremap
nnoremap
" 让编辑模式可以中文输入法下按:转到命令模式
nnoremap : :
" 高亮
syntax on
" 设置高亮搜索
set hlsearch
" 输入字符串就显示匹配点
set incsearch
" 输入的命令显示出来,看的清楚些。
set showcmd
" 打开当前目录文件列表
map
" Taglist
let Tlist_File_Fold_Auto_Close=1
set updatetime=1000
map
" 按 F8 智能补全
inoremap
" vim 自动补全 Python 代码
" 来自http://vim.sourceforge.net/scripts/script.php?script_id=850
autocmd FileType python set complete+=k~/.vim/tools/pydiction
autocmd FileType python set shiftwidth=4 tabstop=4 "expandtab "把tab转化为空格
set list
set lcs=tab:+-,trail:-
" 自动使用新文件模板
autocmd BufNewFile *.py 0r ~/.vim/template/simple.py
autocmd FileType html set shiftwidth=4 tabstop=4 expandtab
autocmd BufNewFile *.html 0r ~/.vim/template/simple.html
"要在命令行上实现 Emacs 风格的编辑操作: >
" 至行首
:cnoremap
" 后退一个字符
:cnoremap
" 删除光标所在的字符
:cnoremap
" 至行尾
:cnoremap
" 前进一个字符
:cnoremap
" 取回较新的命令行
:cnoremap
" 取回以前 (较旧的) 命令行
:cnoremap
" 后退一个单词
:cnoremap
" 前进一个单词
:cnoremap
"Format the statusline
"Nice statusbar
set laststatus=2
set statusline=
set statusline+=%2*%-3.3n%0*/ " buffer number
set statusline+=%f/ " file name
set statusline+=%h%1*%m%r%w%0* " flag
set statusline+=[
if v:version >= 600
set statusline+=%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
endif
set statusline+=%{&fileformat}] " file format
if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
set statusline+=/ %{VimBuddy()} " vim buddy
endif
set statusline+=%= " right align
"set statusline+=%2*0x%-8B/ " current char
set statusline+=0x%-8B/ " current char
set statusline+=%-14.(%l,%c%V%)/ %<%P " offset
参考拓展:
vim配置文件vimrc
Vim的分屏功能
vim encoding and font
vim技巧快捷键学习
vim实用功能总结
VIM编辑代码时的一些技巧
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow