1.在vi 中去掉去掉^M
在WINDOWS/DOS系统和UNIX系统之间交换文件时,因为这两类系统 对于文本的“换行”概念解释不同,所以换行符会出现问题.
:%s/<C-V><C-M>//g 实际是 :%s/^M//g
set fileformat=unix
2.我的.vimrc
" An example for a vimrc file. " " Maintainer: Bram Moolenaar <Bram@vim.org> " Last change: 2006 Nov 16 " " To use it, copy it to " for Unix and OS/2: ~/.vimrc " for Amiga: s:.vimrc " for MS-DOS and Win32: $VIM\_vimrc " for OpenVMS: sys$login:.vimrc " When started as "evim", evim.vim will already have done these settings. if v:progname =~? "evim" finish endif " Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " allow backspacing over everything in insert mode set backspace=indent,eol,start if has("vms") set nobackup " do not keep a backup file, use versions instead else set nobackup " keep [NO] backup file endif set history=250 " keep 250 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries " let &guioptions = substitute(&guioptions, "t", "", "g") " Don't use Ex mode, use Q for formatting map Q gq " In many terminal emulators the mouse works just fine, thus enable it. set mouse=a " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif autocmd VimLeave * \ if has("mksession") && exists("v:this_session") && v:this_session != "" | \ exec "mksession!" v:this_session | \ endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis " Add by Journeylee to make things more easily set softtabstop=4 set shiftwidth=4 set tabstop=4 set noexpandtab set smarttab set showmatch set foldenable set autoindent set smartindent set cindent set foldmethod=marker set background=dark set nobackup set encoding=utf-8 set termencoding=utf-8 language en_US.utf8 set fileencodings=ucs-bom,utf-8,gbk,latin1 set fileformats=unix,dos,mac set fileencoding=utf-8 set fileformat=unix " Make shift-insert work like in Xterm map <S-Insert> <MiddleMouse> map! <S-Insert> <MiddleMouse> " let xterm16_brightness = 'default' " Change if needed " let xterm16_colormap = 'allblue' " Change if needed " colo xterm16 if &term =~ 'xterm\%(-color\)\{,1}' || has('gui_running') let &t_Co = 256 colorscheme colorful256 else let xterm16_colormap = 'allblue' colorscheme xterm16 endif " colorscheme settings let g:php_folding = 3