Aug 17

Felix的vimrc (vim配置文件) 不指定

felix021 @ 2008-8-17 06:10 [IT » 软件] 评论(2) , 引用(0) , 阅读(9541) | Via 本站原创 | |
已经移动到了我的GitHub上:

https://github.com/felix021/myenv/blob/master/.vimrc


=== 以下请忽略 ===


旧版本就不留了,一旦有最新的,我就直接覆盖了

--
@ 2010-12-22 设置dir参数,让.swp文件保存在同一个目录下(详情help directory)
@ 2010-08-18 合并win和linux版本; 重新映射j/k到gj/gk,在自动换行的时候可以上下走动(而不是一次走好几行)。
@ 2010-07-19 linux版增加<C-\>快捷键映射,支持(安装了CTAGS)在新tab中打开光标下的单词
@ 2010-06-08 windows版更新对python文件的基本设置
@ 2010-04-03 windows版更新 G++编译增加一个-D__DEBUG__参数,给<F12>添加的模板增加一个用于调试的宏dp,使用类似printf。
@ 2009-09-12 加入makefile的noexpandtab
@ 2009-05-13 修改CPPSET等函数,在运行的时候打开另一个gnome-terminal; 改用xelatex编译tex文档
@ 2009-04-11 开启modeline, 增加set encoding,能够对付多种编码了:)
@ 2009-04-02
实现的功能是,语法高亮,自动缩进(4格),显示行号,突出当前行,状态栏显示文件路径信息和光标所在行列
F3 显示当前错误
F4 跳转到第一个错误
F5 注释当前行/选中行
F6 取消注释当前行/选中行
F7 显示错误列表
F8 本来是映射到调试,但是发现没什么用,就干脆取消掉了
F9 编译(支持C/C++/Java/PHP/TeX), 对应PHP就是运行,TeX就是pdflatex编译
Ctrl+F9 运行(支持C/C++/Java/PHP/TeX), PHP就是运行,TeX就是evince打开查看
F12 插入C++模板
CTRL+T是:tabedit新建一个tab
普通模式,TAB是:tabnext,下一个tab, SHIFT+TAB是:tabprevious,上一个TAB

编辑模式下快速输入ppp,自动替换为  printf("光标位置");
编辑模式下快速输入sss,自动替换为 scanf("光标位置");
编辑模式下快速输入if(, while(, for(都会自动把后续的){}补全,然后光标停留在()中间
编辑模式下快速输入#inc,自动替换为 #include<[光标位置]>
在普通模式下输入 [,n] 为取消搜索高亮  [,a] 为全选  [Ctrl+C]为复制  [,p] 为粘贴

....

更多功能自己发掘:D

以下是.vimrc的内容:
if v:progname =~? "evim"
  finish
endif
   
set nocompatible

"------------------------------
"Start of Felix's customization


syntax on
set modeline
set fileencodings=ucs-bom,utf-8,gb18030,cp936,big5,euc-jp,sjis,euc-kr,ucs-2le,latin1
set tabstop=4
set softtabstop=4
set shiftwidth=4
set cindent
set expandtab
set cursorline
set number
set scrolloff=3
set sidescrolloff=5
set ignorecase
set magic
set wrap
set mouse=a
set hlsearch
set incsearch
set timeoutlen=350
if has('win32')
    set termencoding=cp936
    set fileformat=dos
    set fileencoding=cp936
    set dir=C:\
else
    set fileformat=unix
    set fileencoding=utf-8
    set dir=/tmp
endif

autocmd FileType c call CPPSET()
autocmd FileType c set makeprg=gcc\ -O2\ -Wall\ -Wno-unused-result\ -o\ %<.exe\ %
autocmd FileType cpp call CPPSET()
autocmd FileType php call PHPSET()
autocmd FileType java call JAVASET()
autocmd FileType python call PYSET()
autocmd FileType make set noexpandtab
set complete+=k

func! CPPSET()
    set cindent
    set makeprg=g++\ -O2\ -Wall\ -Wno-unused-result\ -D__DEBUG__\ -o\ %<.exe\ %
    map <F9> :w!<cr>:make<cr><C-L>:cl<cr>
    map <F8> :!gdb %<.exe<cr><C-L>
    if has('win32')
        map <C-F9> :!start cmd /c "%<.exe && pause \|\| pause"<cr><cr><C-L>
    else
        if has('gui')
            map <C-F9> :!gnome-terminal --command="bash -c 'time \"./%<.exe\"; read -p \"  Press Enter...\"'"&<cr><cr><C-L>
        else
            map <C-F9> :!time ./%<.exe<cr>
        endif
    endif
endfunc

func! PYSET()
    if has('win32')
        map <F9> :w!<cr>:!start cmd /c "python % && pause \|\| pause"<cr><cr><C-L>
        map <C-F9> <esc><F9>
    else
        map <F9> :w!<cr>:!python %<cr>
        map <C-F9> <esc><F9>
    endif
    set expandtab
endfunc

func! PHPSET()
    map <F9> <esc>:w!<cr>:!php -l %<cr>
    set cindent
    if has('win32')
        map <C-F9> :!start cmd /c "d:/web/php/php.exe % && pause \|\| pause"<cr><cr><C-L>
    else
        map <C-F9> <esc>:w!<cr>:!php %<cr>
    endif
endfunc!

func! JAVASET()
    set makeprg=javac\ %
    set cindent
    map <F9> :w!<cr>:make<cr><C-L>:cl<cr>
    "For windows, use
    if has('win32')
        map <C-F9> :!start cmd /c "java %< && pause \|\| pause"<cr><cr><C-L>
    else
        map <C-F9> :!time java "%<"; read -p "Press Enter..."&<cr><cr><C-L>
    endif
endfunc

"F3 for Display Current Error
map <F3> :cc<cr>
"F4 for First Error
map <F4> :cr<cr>:cc<cr>
"F5 for comment
noremap <F5> :s/^\(\s*\)\(\/\/\)*/\1\/\//g<cr>:noh<cr>
"F6 for remove comment
noremap <F6> :s/^\(\s*\)\(\/\/\)*/\1/g<cr>:noh<cr>
"F7 for Error List
map <F7> :cl<cr>

imap <F3> <Esc><F3>
imap <F4> <Esc><F4>
imap <F5> <Esc><F5>
imap <F6> <Esc><F6>
imap <F7> <Esc><F7>
imap <F8> <Esc><F8>
imap <F9> <Esc><F9>
imap <C-F9> <Esc><F9>
imap <F12> <Esc><F12>

imap ppp printf("");<left><left><left>
imap sss scanf("");<left><left><left>
imap #inc  #include <><left>

let mapleader=","

if has('win32')
    set gfn=Consolas:h14
    map <C-S-V> "+p
    imap <C-S-V> <esc><C-S-V>
endif

noremap j gj
noremap k gk

" for select-all, copy, paste
map <leader>a ggVG
map <C-C> "+y
map <leader>p "+p
map <leader>f <c-w><c-f><c-w>T

map <C-T>  :tabedit<CR>
imap <C-T>  <ESC>:tabedit<CR>
map <TAB> :tabnext<CR>
map <S-TAB> <ESC>:tabprevious<CR>
" ,n for no highlight search(temporary)
nmap <leader>n :noh<cr>

if has('win32')
    map <F11> <esc>:cd d:/code<cr>
else
    map <F11> <esc>:cd ~/code<cr>
endif

" F12 to insert template
map <F12> <Esc>ggdG:call Template()<cr>/main<cr>:noh<cr>jo
func! Template()
call setline(1,        "#include<iostream>")
call append(line('$'), "#include<algorithm>")
call append(line('$'), "#include<cstdio>")
call append(line('$'), "#include<cstdlib>")
call append(line('$'), "#include<set>")
call append(line('$'), "#include<map>")
call append(line('$'), "#include<vector>")
call append(line('$'), "using namespace std;")
call append(line('$'), "#ifdef __DEBUG__")
call append(line('$'), "#define dp(fmt, x...) fprintf(stderr, \"[%d] \" fmt, __LINE__, ##x)")
call append(line('$'), "#else")
call append(line('$'), "#define dp(fmt, x...)")
call append(line('$'), "#endif")
call append(line('$'), "")
call append(line('$'), "int main()")
call append(line('$'), "{")
call append(line('$'), "    return 0;")
call append(line('$'), "}")
call append(line('$'), "")
endfunc

" status line
set laststatus=2
set statusline=\ %F%m%r\ \ \ %{getcwd()}%h\ \ \ Line:\ %l/%L:%c

"End of Felix's customization
"----------------------------

set backspace=indent,eol,start
set nobackup    " do not keep a backup file, use versions instead
set history=50    " keep 50 lines of command line history
set ruler    " show the cursor position all the time
set showcmd    " display incomplete commands
set incsearch    " do incremental searching
" Don't use Ex mode, use Q for formatting
map Q gq
set mouse=a
syntax on
set hlsearch
if has("autocmd")
  filetype plugin indent on
  augroup vimrcEx
  au!
  autocmd FileType text setlocal textwidth=78
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \  exe "normal! g`\"" |
    \ endif
  augroup END
else
  set cindent
endif " has("autocmd")

command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
    \ | wincmd p | diffthis

noremap <F1> <esc>
vnoremap <F1> <esc>
inoremap <F1> <esc>




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
Tags:
fuc-kyou
2009-6-1 13:20
zan
felix021 回复于 2009-6-1 13:53
Orz
fuc-kyou
2009-6-1 13:20
stupid
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]