欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

linux Vim经典配置一例

程序员文章站 2023-11-10 09:11:58
把如下的文件保存为Linux主文件夹的".vimrc"文件(不同的Linux版本略有不同,ubuntu下是.vimrc),即可以把vim打造成一把利器... 13-02-11...
有需要的朋友可以参考下。

复制代码
代码如下:

" this is my _vimrc under windows platform
" and it can be used on *nix too
" all the difference of them is the font setting session
" happy viming,
" copyleft (#) abruzzi john

set linebreak " line break
set nocompatible " no compatible
set history=400 " history
set ruler
set number " line number
set hlsearch " highlight search
set noincsearch " no in c search
set expandtab " expand table
set t_vb= "close bell
set foldmethod=marker
set tabstop=4 " table step
set shiftwidth=4
set nobackup " don't backup
set smarttab " smart table
set smartindent " smart indent
set autoindent " auto indent
set cindent "cindent
set cursorline " hightlight cursor line 高亮光标所在行

" set the back space
set backspace=indent,eol,start "这行比较重要,刚接触vim的朋友会发现有时候backspace键删不了文字

colorscheme desert " color scheme

let tlist_use_right_window=0 " for tag_list plugin only
let tlist_file_fold_auto_close=1 " for tag_list plugin only

let g:winmanagerwindowlayout="fileexplorer|taglist" " for winmanager

filetype plugin indent on " filetype setting
set completeopt=longest,menu " for code complete

" the following function is used for show the status bar on the buttom
function! currectdir()
let curdir = substitute(getcwd(), "", "", "g")
return curdir
endfunction
set statusline=\ [file]\ %f%m%r%h\ %w\ \ [pwd]\ %r%{currectdir()}%h\ \ %=[line]\ %l,%c\ %=\ %p

" this is a setting of font
if has("win32")
set guifont=courier_new:h10:cansi
endif

" make sure that syntax always on
if exists("syntax_on")
syntax reset
else
syntax on
endif


" java complete
if has("autocmd")
autocmd filetype java setlocal omnifunc=javacomplete#complete
endif

""""""""""""""""""""""""""""""""""""""""""""""""""""""
let performance_mode=1

function mysys()
if has("win32")
return "win32"
elseif has("unix")
return "unix"
else
return "mac"
endif
endfunction

if mysys() == "unix" || mysys() == "mac"
set shell=bash
else
" set win32 shell
endif

" set auto read when file is changed from outside
if exists("&autoread")
set autoread
endif

" enable the mouse
if exists("&mouse")
set mouse=a
endif

" set mapleader
let mapleader=","
let g:mapleader=","

"fast saving
nmap <leader>x :xa!<cr>
nmap <leader>w :w!<cr>

"switch to current directory
map <leader>cd :cd %:p:h<cr>

" just for fun
map <f9> ggvgg?

" folding code
if exists("&foldenable")
set fen
endif

if exists("&foldlevel")
set fdl=0
endif

" tag list --
map <f3> :tlist<cr>

"remove the windows ^m windows系统中常常可以看到文本中夹杂着^m这样的控制字符,用此命令删除之
noremap <leader>m :%s/