先谢谢楼上的关注。
不过,不是这个问题(而且,我点出的第一个问题,是ubuntu下的vim有不爽的地方,即不能马上把我当前的按键显示来),因为我不是用的原始的vimrc,甚至mswin.vim文件都被我删除了。
我还是贴一下我的vimrc吧,希望不会因为太长,而占了各位的眼睛:
" vim : ts=8 ff=unix sw=4 enc=gbk fenc=gbk et:
"
"
"" Fileencodings Priority : ucs-bom, utf-8; 2cd, gbk;
"" NOTE: `bom` is short for Byte Order Mask'
"
"" Multi-encoding setting, MUST BE IN THE BEGINNING OF .vimrc!
"
if has("multi_byte")
" When 'fileencodings' starts with 'ucs-bom', don't do this manually
" "set bomb
set fileencodings=ucs-bom,utf-8,chinese,taiwan,japan,korea,latin1
" CJK environment detection and corresponding setting
if v:lang =~ "^zh_CN"
" Simplified Chinese, on Unix euc-cn, on MS-Windows cp936
set encoding=chinese
set termencoding=chinese
if &fileencoding == ''
set fileencoding=chinese
elseif &fileencoding == "utf8"
set encoding = utf8
endif
elseif v:lang =~ "^zh_TW"
" Traditional Chinese, on Unix euc-tw, on MS-Windows cp950
set encoding=taiwan
set termencoding=taiwan
if &fileencoding == ''
set fileencoding=taiwan
endif
elseif v:lang =~ "^ja_JP"
" Japanese, on Unix euc-jp, on MS-Windows cp932
set encoding=japan
set termencoding=japan
if &fileencoding == ''
set fileencoding=japan
endif
elseif v:lang =~ "^ko"
" Korean on Unix euc-kr, on MS-Windows cp949
set encoding=korea
set termencoding=korea
if &fileencoding == ''
set fileencoding=korea
endif
endif
" Detect UTF-8 locale, and override CJK setting if needed
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set encoding=utf-8
endif
else
echoerr 'Sorry, this version of (g)Vim was not compiled with "multi_byte"'
endif
if has('gui_gtk2')
set guifont=Courier\ New\ 12
endif
" return OS type, eg: windows, or linux, mac, et.st..
function! MySys()
if has("win16") || has("win32") || has("win64") || has("win95")
return "windows"
elseif has("unix")
return "linux"
endif
endfunction
" Recognize standard C/C++ headers
"For $include
if MySys() == "windows"
set path=.,C:/MinGW/include,C:/MinGW/include/c++/3.4.5,E:/MyProject/MyProject.Tool/include,,
elseif MySys() == "linux"
set path=.,/usr/include/,/usr/include/c++/4.1.3/,,
endif
"For ctags file!
if MySys() == "windows"
set tags+=C:/MinGW/include/ctags
set tags+=C:/MinGW/include/c++/3.4.5/stl.tags
elseif MySys() == "linux"
set tags+=/usr/include/ctag
set tags+=/usr/include/c++/4.1.3/ctags
endif
" Recognize standard C++ headers
if MySys() == "windows"
au BufEnter C:/MinGW/include/* setf cpp
au BufEnter C:/MinGW/include/c++/3.4.5/* setf cpp
elseif MySys() == "linux"
au BufEnter /usr/include/c++/* setf cpp
au BufEnter /usr/include/c++/4.1.3/* setf cpp
endif
" function for font!
function! Set_nomo_font()
if MySys() == "windows"
"set gfn=Courier_New:h10:cANSI
set gfn=Consolas:h10:cANSI
elseif MySys() == "linux"
set gfn=Courier\ New\ 10
endif
endfunction
function! Set_text_font()
if MySys() == "windows"
set gfn=新宋体:h12:cANSI
"set gfn=Consolas:h12:cANSI
elseif MySys() == "linux"
set gfn=Bitstream\ Vera\ Sans\ Mono\ 10
endif
endfunction
func! g:SaveAsPlainText()
"TODO:return to original position
let l:line = getline(1)
let l:line = matchstr(l:line, '^\%(\*\+\s\+\)\=\zs.\+$')
let l:title = matchstr(l:line, '^[ ]*\zs.\+$')
" \([^\s ].\{-1,}\)[\s ]*$/\1/g
exe ':w '. l:title .'.txt'
endf
command! SText call g:SaveAsPlainText()
func! g:TrimTrailingSpaces()
"TODO:return to original position
silent %s/\(\s\| \)\+$//g
endf
command! TTrailingSpaces call g:TrimTrailingSpaces()
"set guifontset=-*-fixed-medium-r-normal--14-*-*-*-c-*-*-*,*
"改为你喜欢的字体
"" with command 'filetype on', gvim will source '$VIMRUNTIME/filetype.vim'
"" to sort file with file extension and file content;
"" the below command will do the following three things:
filetype on
filetype plugin on
filetype indent on
" and only one line for short ^_^
" filetype plugin indent on
""Color Scheme Setting
" colorscheme darkblue " torte || murphy
colorscheme desertEx
"" Auto-indent setting For All
set autoindent " Auto-indent on
set nobackup " No backups
set noswapfile " No swap file, use memory only
set nocompatible " No compatible with VI
"language "en_US.ISO_8859-1"
"用于新建文件
set fileencoding=gbk
"
"控制欢迎字幕以及状态条语言
let $lang = 'EN-US' " United Stats English
set helplang=en " 帮助文件的语言
"" with command 'filetype on', gvim will source '$VIMRUNTIME/filetype.vim'
"" to sort file with file extension and file content;
"" the below command will do the following three things:
filetype on
filetype plugin on
filetype indent on
"" and only one line for short ^_^
"filetype plugin indent on
" Text file Formating Settings
" Command:
" gq
"set formatoptions+=mM
" Enhence '%' -- 'match it'
let s:chinese_punct_match_words = '「:」,[:],【:】,{:},《:》,『:』,“:”,‘:’,(:),\(,\|、\):\(。\|?\|!\)'
let s:none_punct = '\s\|\w'
let s:left_ankle = '\('.s:none_punct .'\|^\)'.'\@<='.'<\('.s:none_punct .'\|$\)\@='
let s:right_ankle = '\('.s:none_punct .'\|^\)'.'\@<='.'>\('.s:none_punct .'\|$\|\:\|(\|{\)\@='
" Viki
let g:vikiNameSuffix=".viki"
augr viki
au!
autocmd! BufRead,BufNewFile *.viki set filetype=viki
augr END
" My file type and extension !
au BufNewFile,BufRead,BufWrite *.txt setf plaintext
au BufNewFile,BufRead,BufWrite *.etd setf easytodo " easy to do file !
au BufNewFile,BufRead,BufWrite *.zlg setf ztxlog " zhongwen text log file !
" PowerShell
au BufNewFile,BufRead,BufWrite *.ps1,*.psc1 setf ps1 |
\call Set_nomo_font()
au FileType plaintext set ts=8 sw=8 nu noet fo+=mM tw=80 |
\call Set_text_font() |
\let b:match_words = s:chinese_punct_match_words
au FileType easytodo let b:match_words = s:chinese_punct_match_words | set ts=4
au FileType ztxlog let b:match_words = s:chinese_punct_match_words | set ts=4
"" for warning trimling spaces highligting set
let c_space_errors = 1
" in $VIMRUNTIM/syntax/c.vim
" DATE:2008.6.14
"" sw : shiftwidth; ts : tabstop; et : expandtab; gfn : guifont; nu : number; fdm : foldermethod;
"" this is for *.c, *.cpp, *.h, *.hpp, *.cc, *.cxx ... source file
au FileType c,cpp,java set cin cino=:0,g0,t0 ts=8 sw=4 et nu fdm=marker |
\call Set_nomo_font()
au FileType cpp let b:match_words = ''.s:left_ankle .':'.s:right_ankle
au FileType make set nocin sw=4 ts=4 noet |
\call Set_nomo_font()
"" this is for HTML file, eg, html, xhtml ...
au FileType html,xhtml,aspvbs set sw=2 ts=2 nu tw=80 fo+=mM |
\call Set_text_font() |
\let b:match_words .= ','.s:chinese_punct_match_words
au FileType dosbatch set sw=4 ts=4 nu |
\call Set_nomo_font()
"" this is for vim help file, the extension is default as *.txt
au FileType help set sw=4 ts=8 nu fdm=marker |
\call Set_nomo_font()
"" this is for vim help file, the extension is default as *.txt
au FileType vim set sw=4 ts=8 nu fdm=marker |
\call Set_nomo_font()
"" these will make navigate in chinese text file much easier!
"" Session as a project Manager
"silent source! Session.vim
"the command above will automatic open the file:Session.vim under current work
"directory, when you open a file.
"This makes much easier when manage a project, such as a C/C++ programe.
"autocmd BufRead, BufEnter
"" Browse Mode Setting
set nostartofline " Keep cursor column when moving
set nocompatible " Use vim advance settings; do not compatible with VI
"" Help Language Setting
set helplang=en " Language of help
set showcmd " Show commond line
"" Status Bar Setting
set laststatus=2 " Always show status line
set statusline=%f%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
"" Command Line Setting
set cmdheight=1 " lines for command window
"" Howto Fold text default: start with {{{ end with }}}}
set foldmethod=marker " fold method to marker
"" every time read a file, just maximum the window
" Simulate <Ctrl-Space>
if MySys() == "windows"
" au BufRead * simalt ~x "
http://www.aspxml.cn/Article/WebDevelop ... /2522.html
elseif MySys() == "linux"
"
endif
"in $VIM\vim70\ftplugin directory to docbk.vim, xsl.vim, html.vim, xhtml.vim
"let cscopeprg=$VIMRUNTIME . 'cscope.exe'
"" Inner Search Mode
set incsearch " Increase search ON
"" use <F2> to invalide Search HighLighting
nmap <F2> :set hls!<CR>
"" The <Backspace> Behavior
set backspace=indent,eol,start " Backspace over everyting
"" Maxmum Commands to be saved
set history=50 " Save at most 50 commands
"" GUI Frame Setting
set guioptions-=L " No left hand scrollbars
set guioptions-=r " No right hand scrollbars
set guioptions-=T " No Toolbar
"set guioptions-=m " No menu bar
filetype plugin on
"" the appearence of line number
hi LineNr guifg=#008f00 gui=bold guibg=#222222
"" Table window Navigation
"" Move foreward : Ctrl-Tab
nmap <c-tab> :tabn<cr>
"" Move backward : Ctrl-Shift-Tab
nmap <c-s-tab> :tabp<cr>
""""""""""""""""""""""""""""""
" OmniCppComplete setting
""""""""""""""""""""""""""""""
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
" set g:ctags_command for toolbar
"let g:ctags_command='ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .'
""from 御剑飞仙的_gvimrc
""""""""""""""""""""""""""""""
" Code_Complete plugin autocommand
""""""""""""""""""""""""""""""
au FileType c,cpp call CodeCompleteStart()
""""""""""""""""""""""""""""""
" BufExplorer
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0 " 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.
""""""""""""""""""""""""""""""
" lookupfile setting
""""""""""""""""""""""""""""""
let g:LookupFile_MinPatLength = 2 "最少输入2个字符才开始查找
let g:LookupFile_PreserveLastPattern = 0 "不保存上次查找的字符串
let g:LookupFile_PreservePatternHistory = 1 "保存查找历史
let g:LookupFile_AlwaysAcceptFirst = 1 "回车打开第一个匹配项目
let g:LookupFile_AllowNewFiles = 0 "不允许创建不存在的文件
if filereadable("./filenametags") "设置tag文件的名字
let g:LookupFile_TagExpr = '"./filenametags"'
endif
nmap <silent> <leader>lk <Plug>LookupFile<cr>
"映射LookupFile为,lk
nmap <silent> <leader>ll :LUBufs<cr>
"映射LUBufs为,ll
nmap <silent> <leader>lw :LUWalk<cr>
"映射LUWalk为,lw
runtime plugin\cscope_maps.vim " source $VIMRUNTIME\plugin\cscope_maps.vim
runtime vimrc_example.vim " source $VIMRUNTIME\vimrc_example.vim
" source $VIMRUNTIME\mswin.vim ---- something in this vimfile is bad for new pie
" behave mswin ---- bad for new pie, too.
" Copy to Clipboard for Win32 Compatibility
" Copy current selet text to register |quotequote|
"vnoremap <C-c> "*y
" Cursor movement
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
nnoremap <End> g$
nnoremap <Home> g0
vnoremap <End> g$
vnoremap <Home> g0
inoremap <End> <C-o>g$
inoremap <Home> <C-o>g0
" Close current file window
nmap <C-F4> :confirm bd<CR>
vmap <C-F4> <ESC>:confirm bd<Enter>
omap <C-F4> <ESC>:confirm bd<Enter>
map! <C-F4> <ESC>:confirm bd<Enter>
"noremap <C-F4> <C-W>c
"inoremap <C-F4> <C-O><C-W>c
"cnoremap <C-F4> <C-C><C-W>c
"onoremap <C-F4> <C-C><C-W>c
" Move lines
nmap <C-Down> :<C-u>move .+1<CR>
nmap <C-Up> :<C-u>move .-2<CR>
imap <C-Down> <C-o>:<C-u>move .+1<CR>
imap <C-Up> <C-o>:<C-u>move .-2<CR>
vmap <C-Down> :move '>+1<CR>gv
vmap <C-Up> :move '<-2<CR>gv
" Toggle line number
nmap <C-F12> :set nu!<CR>
imap <C-F12> <C-o>:set nu!<CR>
" Toggle spell check
" For VIM7 only
nmap <C-F11> :set spell!<CR>
imap <C-F11> <C-o>:set spell!<CR>
" CTRL-Tab is Next window
"noremap <C-Tab> <C-W>w
"inoremap <C-Tab> <C-O><C-W>w
"cnoremap <C-Tab> <C-C><C-W>w
"onoremap <C-Tab> <C-C><C-W>w
" Buffer Cycling
map <C-right> <ESC>:bnext<CR>
map <C-left> <ESC>:bprevious<CR>
"NOTE:{{{
"if you want to toggle back and forth between current and previous buffer,
"then you can use CTRL-6(CTRL-o CTRL-6 if in insert mode)or
":e #
"}}}
" Open and locate a Help Window faster
map <F1> <ESC>:exec "help ".expand("<cword>")<CR>
"NOTE:{{{
"To get the word under the cursor, we use <cWORD>. The WORD part is uppercase;
"this means that all characters except white spaces (space and tab) can be
"part of the word. This is needed because VIM commands can contain special
"characters other than alphanumeric (think of if you were to look up <cWORD>).
"}}}
" Alt-Space is System menu
if has("gui")
noremap <M-Space> :simalt ~<CR>
inoremap <M-Space> <C-O>:simalt ~<CR>
cnoremap <M-Space> <C-C>:simalt ~<CR>
endif
" Navigating among multiple files, eg, editing C/C++ files
"open a new buffer, not current window, to view referenced file
map gF :tabedit <cfile><CR>
"NOTE:{{{
"if <cfile> contains white space, you can just select them, and
"then press gf in normal mode.}}}
set includeexpr=substitute(v:fname,'\\.','/','g')
"NOTE:{{{
"if <cfile> not finded
"substitute <cfile>, like this:
"java.com.http -> java/com/http.java }}}
"===================================================================
" function MyDiff
"===================================================================
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 =~ '\<cmd'
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
endfunction "}}}
"ca e tabe
"colorscheme InkPot " my favorite dark theme
"colorscheme TAqua " my favorite light theme
au GUIEnter * simalt ~x " maxmize the window when start
""from 御剑飞仙的_gvimrc
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""
if MySys() == "windows" "设定windows系统中ctags程序的位置
let Tlist_Ctags_Cmd = 'ctags'
"For ctags file!
set tags+=C:/MinGW/include/ctags
set tags+=C:/MinGW/include/c++/3.4.5/stl.tags
elseif MySys() == "linux" "设定linux系统中ctags程序的位置
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
"For ctags file!
set tags+=/usr/include/ctags
set tags+=/usr/include/c++/4.1.3/stl.tags
endif
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
""""""""""""""""""""""""""""""
"" Auto-indent setting For All
set autoindent " Auto-indent on
set nobackup " No backups
set noswapfile " No swap file, use memory only
set nocompatible " No compatible with VI
最后,我要说一下,我在两个操作系统下的gvimrc都是空的文件,0byte,免得两个地方修改。