|
我输入source /root/.vimrc 时候
输出
-bash: Platform
function! MySys()
return linux
endfunction
: command not found
-bash: .vimrc: line 7: syntax error near unexpected token `('
-bash: .vimrc: line 7: `function! SwitchToBuf(filename)'
/root/.vimrc
文件具体如下
" Platform
function! MySys()
return "linux"
endfunction
" Switch to buffer according to file name
function! SwitchToBuf(filename)
let fullfn = substitute(a:filename, "^\\~/", $HOME . "/", "")
" find in current tab
let bufwinnr = bufwinnr(fullfn)
if bufwinnr != -1
exec bufwinnr . "wincmd w"
return
else
" find in each tab
tabfirst
let tab = 1
while tab <= tabpagenr("$")
let bufwinnr = bufwinnr(fullfn)
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 " . fullfn
endif
endfunction
"Fast edit vimrc
if MySys() == 'linux'
"Fast reloading of the .vimrc
map <silent> <leader>s :source ~/.vimrc<cr>
"Fast editing of .vimrc
map <silent> <leader>e :call SwitchToBuf("~/.vimrc")<cr>
"When .vimrc is edited, reload it
autocmd! bufwritepost .vimrc source ~/.vimrc
elseif MySys() == 'windows'
"Fast reloading of the _vimrc
map <silent> <leader>s :source ~/_vimrc<cr>
"Fast editing of _vimrc
map <silent> <leader>e :call SwitchToBuf("~/_vimrc")<cr>
"When _vimrc is edited, reload it
autocmd! bufwritepost _vimrc source ~/_vimrc
endif
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2008 Jul 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc |
|