LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1144|回复: 5

[求助]关于配置vi?

[复制链接]
发表于 2005-11-30 18:05:22 | 显示全部楼层 |阅读模式
如何配置vi,才能够达到Mandriva中那样的效果呢——(编程时)自动缩进、高亮显示、退格键不再受限……

请明白人详细说明!
发表于 2005-11-30 19:47:14 | 显示全部楼层
  1. " Configuration file for vim
  2. set runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles,/usr/share/vim/addons,/usr/share/vim/vim63,/usr/share/vim/vimfiles,/usr/share/vim/addons/after,~/.vim/after

  3. " Normally we use vim-extensions. If you want true vi-compatibility
  4. " remove change the following statements
  5. set nocompatible        " Use Vim defaults instead of 100% vi compatibility
  6. set backspace=indent,eol,start        " more powerful backspacing

  7. " Now we set some defaults for the editor
  8. " set autoindent        " always set autoindenting on
  9. " set linebreak                " Don't wrap words by default
  10. set textwidth=0                " Don't wrap lines by default
  11. set nobackup                " Don't keep a backup file
  12. set viminfo='20,"50        " read/write a .viminfo file, don't store more than
  13.                         " 50 lines of registers
  14. set history=50                " keep 50 lines of command line history
  15. set ruler                " show the cursor position all the time

  16. " Suffixes that get lower priority when doing tab completion for filenames.
  17. " These are files we are not likely to want to edit or read.
  18. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

  19. " We know xterm-debian is a color terminal
  20. if &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
  21.   set t_Co=16
  22.   set t_Sf=[3%dm
  23.   set t_Sb=[4%dm
  24. endif

  25. " Make p in Visual mode replace the selected text with the "" register.
  26. vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>

  27. " Vim5 and later versions support syntax highlighting. Uncommenting the next
  28. " line enables syntax highlighting by default.
  29. syntax on

  30. " Hilight the search results
  31. set hlsearch

  32. " Encoding auto detection
  33. set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

  34. " If using a dark background within the editing area and syntax highlighting
  35. " turn on this option as well
  36. " set background=dark

  37. if has("autocmd")
  38. " Enabled file type detection
  39. " Use the default filetype settings. If you also want to load indent files
  40. " to automatically do language-dependent indenting add 'indent' as well.
  41. filetype plugin on

  42. endif " has ("autocmd")

  43. " Some Debian-specific things
  44. augroup filetype
  45.   au BufRead reportbug.*                set ft=mail
  46.   au BufRead reportbug-*                set ft=mail
  47. augroup END

  48. " Set paper size from /etc/papersize if available
  49. try
  50.   if filereadable('/etc/papersize')
  51.     let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
  52.     if strlen(s:papersize)
  53.       let &printoptions = "paper:" . s:papersize
  54.     endif
  55.     unlet! s:papersize
  56.   endif
  57. catch /E145/
  58. endtry

  59. " The following are commented out as they cause vim to behave a lot
  60. " different from regular vi. They are highly recommended though.
  61. "set showcmd                " Show (partial) command in status line.
  62. "set showmatch                " Show matching brackets.
  63. "set ignorecase                " Do case insensitive matching
  64. "set incsearch                " Incremental search
  65. "set autowrite                " Automatically save before commands like :next and :make

  66. " Source a global configuration file if available
  67. if filereadable("/etc/vim/vimrc.local")
  68.   source /etc/vim/vimrc.local
  69. endif
复制代码
回复 支持 反对

使用道具 举报

发表于 2005-11-30 23:10:43 | 显示全部楼层
自动缩进 filetype ident on
高亮显示 sy on
退格键不再受限 set bs=2
回复 支持 反对

使用道具 举报

发表于 2005-12-1 12:28:00 | 显示全部楼层
我一般只是复制安装目录下的配置文件到 ~/.vimrc。
回复 支持 反对

使用道具 举报

发表于 2005-12-5 01:32:54 | 显示全部楼层
请问suse 10 的vi配置文件在那里?还有,在vi命令行的配置是否只是对当前的文件有效?我以前用的是Mandriva,好怀念,那位大虾可以帮帮我阿~~
回复 支持 反对

使用道具 举报

发表于 2005-12-5 11:37:19 | 显示全部楼层
印象中好像是 /usr/share/vim. . .
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表