免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5945 | 回复: 12
打印 上一主题 下一主题

[FreeBSD] FreeBSD里的VI可是设置高亮吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-02 13:15 |只看该作者 |倒序浏览
FreeBSD里的VI可是设置高亮吗?它的配置文件在哪?

论坛徽章:
0
2 [报告]
发表于 2007-03-02 13:17 |只看该作者
原帖由 painkiller0513 于 2007-3-2 13:15 发表
FreeBSD里的VI可是设置高亮吗?它的配置文件在哪?


no.
use vim.

论坛徽章:
0
3 [报告]
发表于 2007-03-02 13:20 |只看该作者
VIM也没有高亮,我就是找不到配置文件在哪里?

论坛徽章:
0
4 [报告]
发表于 2007-03-02 13:34 |只看该作者
原帖由 painkiller0513 于 2007-3-2 13:20 发表
VIM也没有高亮,我就是找不到配置文件在哪里?


vim的安装目录下有个缺省配置文件示例,将其拷贝至你的主目录下,改名为.vimrc

论坛徽章:
0
5 [报告]
发表于 2007-03-02 14:13 |只看该作者
我的VIM是在安装系统是安装的。没有安装目录,麻烦你贴一上来,好吗?

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
6 [报告]
发表于 2007-03-02 14:18 |只看该作者
把这个贴到~/.vimrc里 没有这个文件就自己建一个

  1. " vim:shiftwidth=2:tabstop=8:expandtab

  2. if has('autocmd')
  3.   " Remove ALL autocommands for the current group
  4.   au!

  5.   " Mark .asm files MASM-type assembly
  6.   au BufNewFile,BufReadPre *.asm let b:asmsyntax='masm'
  7. endif

  8. if has('gui_running')
  9.   let do_syntax_sel_menu=1
  10. endif

  11. if has('gui_running') && $LANG !~ '\.'
  12.   set encoding=utf-8
  13. endif

  14. set nocompatible
  15. source $VIMRUNTIME/vimrc_example.vim

  16. set autoindent
  17. set nobackup
  18. set showmatch
  19. set formatoptions+=mM
  20. set fileencodings=ucs-bom,utf-8,gbk
  21. set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
  22. if has('mouse')
  23.   set mouse=a
  24. endif
  25. if has('multi_byte') && v:version > 601
  26.   if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
  27.     set ambiwidth=double
  28.   endif
  29. endif

  30. " Key mappings to ease browsing long lines
  31. noremap  <C-J>       gj
  32. noremap  <C-K>       gk
  33. noremap  <Down>      gj
  34. noremap  <Up>        gk
  35. inoremap <Down> <C-O>gj
  36. inoremap <Up>   <C-O>gk

  37. " Key mappings for quick arithmetic inside Vim
  38. nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$
  39. vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$
  40. nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$
  41. vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap

  42. " Key mapping to stop the search highlight
  43. nmap <silent> <F2>      :nohlsearch<CR>
  44. imap <silent> <F2> <C-O>:nohlsearch<CR>

  45. " Key mapping for the taglist.vim plugin
  46. nmap <F9>      :Tlist<CR>
  47. imap <F9> <C-O>:Tlist<CR>

  48. " Key mappings for the quickfix commands
  49. nmap <F11> :cn<CR>
  50. nmap <F12> :cp<CR>

  51. " Non-GUI setting
  52. if !has('gui_running')
  53.   " Do not increase the windows width in the taglist.vim plugin
  54.   if has('eval')
  55.     let Tlist_Inc_Winwidth=0
  56.   endif

  57.   " Set text-mode menu
  58.   if has('wildmenu')
  59.     set wildmenu
  60.     set cpoptions-=<
  61.     set wildcharm=<C-Z>
  62.     nmap <F10>      :emenu <C-Z>
  63.     imap <F10> <C-O>:emenu <C-Z>
  64.   endif
  65. endif

  66. if has('autocmd')
  67.   function! SetFileEncodings(encodings)
  68.     let b:my_fileencodings_bak=&fileencodings
  69.     let &fileencodings=a:encodings
  70.   endfunction

  71.   function! RestoreFileEncodings()
  72.     let &fileencodings=b:my_fileencodings_bak
  73.     unlet b:my_fileencodings_bak
  74.   endfunction

  75.   function! CheckFileEncoding()
  76.     if &modified && &fileencoding != ''
  77.       exec 'e! ++enc=' . &fileencoding
  78.     endif
  79.   endfunction

  80.   function! ConvertHtmlEncoding(encoding)
  81.     if a:encoding ==? 'gb2312'
  82.       return 'gbk'              " GB2312 imprecisely means GBK in HTML
  83.     elseif a:encoding ==? 'iso-8859-1'
  84.       return 'latin1'           " The canonical encoding name in Vim
  85.     elseif a:encoding ==? 'utf8'
  86.       return 'utf-8'            " Other encoding aliases should follow here
  87.     else
  88.       return a:encoding
  89.     endif
  90.   endfunction

  91.   function! DetectHtmlEncoding()
  92.     if &filetype != 'html'
  93.       return
  94.     endif
  95.     normal m`
  96.     normal gg
  97.     if search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html; charset=[-A-Za-z0-9_]\+">') != 0
  98.       let reg_bak=@"
  99.       normal y$
  100.       let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')
  101.       let charset=ConvertHtmlEncoding(charset)
  102.       normal ``
  103.       let @"=reg_bak
  104.       if &fileencodings == ''
  105.         let auto_encodings=',' . &encoding . ','
  106.       else
  107.         let auto_encodings=',' . &fileencodings . ','
  108.       endif
  109.       if charset !=? &fileencoding &&
  110.             \(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding == '')
  111.         silent! exec 'e ++enc=' . charset
  112.       endif
  113.     else
  114.       normal ``
  115.     endif
  116.   endfunction

  117.   function! GnuIndent()
  118.     setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
  119.     setlocal shiftwidth=2
  120.     setlocal tabstop=8
  121.   endfunction

  122.   function! RemoveTrailingSpace()
  123.     if $VIM_HATE_SPACE_ERRORS != '0' &&
  124.           \(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')
  125.       normal m`
  126.       silent! :%s/\s\+$//e
  127.       normal ``
  128.     endif
  129.   endfunction

  130.   " Highlight space errors in C/C++ source files (Vim tip #935)
  131.   if $VIM_HATE_SPACE_ERRORS != '0'
  132.     let c_space_errors=1
  133.   endif

  134.   " Use Canadian spelling convention in engspchk (Vim script #195)
  135.   let spchkdialect='can'

  136.   " Show syntax highlighting attributes of character under cursor (Vim
  137.   " script #383)
  138.   map <Leader>a :call SyntaxAttr()<CR>

  139.   " Automatically find scripts in the autoload directory
  140.   au FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'

  141.   " File type related autosetting
  142.   au FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4
  143.   au FileType diff  setlocal shiftwidth=4 tabstop=4
  144.   au FileType html  setlocal autoindent indentexpr=
  145.   au FileType changelog setlocal textwidth=76

  146.   " Text file encoding autodetection
  147.   au BufReadPre  *.gb               call SetFileEncodings('gbk')
  148.   au BufReadPre  *.big5             call SetFileEncodings('big5')
  149.   au BufReadPre  *.nfo              call SetFileEncodings('cp437')
  150.   au BufReadPost *.gb,*.big5,*.nfo  call RestoreFileEncodings()
  151.   au BufWinEnter *.txt              call CheckFileEncoding()

  152.   " Detect charset encoding in an HTML file
  153.   au BufReadPost *.htm* nested      call DetectHtmlEncoding()

  154.   " Recognize standard C++ headers
  155.   au BufEnter /usr/include/c++/*    setf cpp
  156.   au BufEnter /usr/include/g++-3/*  setf cpp

  157.   " Setting for files following the GNU coding standard
  158.   au BufEnter /usr/*                call GnuIndent()

  159.   " Remove trailing spaces for C/C++ and Vim files
  160.   au BufWritePre *                  call RemoveTrailingSpace()
  161. endif
  162. "me add
  163. "autocmd BufNewFile *.c exec append(0,"/*   */")|exec append(1,"#include <stdio.h>") |exec append(2,"int main(void)")|exec append(3,"{")|exec append(5,"        return 0;")|exec append(6,"}")| exec ':0'
  164. autocmd BufNewFile *.c exec append(0,"#include <stdio.h>") |exec append(1,"int main(void)")|exec append(2,"{")|exec append(4,"        return 0;")|exec append(5,"}")| exec ':4'
  165. autocmd BufNewFile *.pl exec append(0,"#!/usr/bin/perl -w") | exec append(1,"use strict;") | exec append(2,"use warnings;") | exec ':$'
  166. "autocmd BufNewFile *.py 0r ~/.vim/skeleton/skeleton.py
  167. map <F3> ^i#<ESC>
  168. map <F2> ^x
  169. set viminfo='200,\"500
  170. set history=500
  171. set number
复制代码

论坛徽章:
0
7 [报告]
发表于 2007-03-03 21:15 |只看该作者
狗狗真强悍,我看的云里雾里...能不能大致说说哇

论坛徽章:
0
8 [报告]
发表于 2007-03-03 23:14 |只看该作者
进入vim,然后在vim执行命令:
:!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc

论坛徽章:
0
9 [报告]
发表于 2007-03-03 23:18 |只看该作者
原帖由 zwylinux 于 2007-3-3 23:14 发表
进入vim,然后在vim执行命令:
:!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc

谢谢

我在拷贝前 做了  cp  ~/.vimrc  ~/.vimrc.bak

[ 本帖最后由 爱打瞌睡的小猪 于 2007-3-3 23:23 编辑 ]

论坛徽章:
0
10 [报告]
发表于 2007-03-04 11:55 |只看该作者
狗狗的.vimrc真强,弄的VIM跟我的Emacs似的,写C代码挺方便的。

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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP