如何用Linux配置vi环境,自用vim环境参数设置

set nu mber 显示行号

syntax on 语法高亮

set cursorline 用浅色高亮当前行

set ruler 显示标尺

set showcmd 输入的命令显示出来,看的清楚些

set cmdheight=1 命令行(在状态行下)的高度,设置为1

set tabstop=4 设置tab为四个空格

set hlsearch 搜索时高亮显示被找到的文本

set smartindent 开启新行时使用智能自动缩进

插件设置

filetype plugin on 允许插件

if has(‘/opt/local/bin/ctags’)

let Tlist_Ctags_Cmd=’/opt/local/bin/ctags’

endif

” Taglist plugin

map :TlistToggle

let Tlist_WinWidth = 30

let Tlist_Use_Right_Window = 1

let Tlist_Use_SingleClick = 1

let Tlist_Show_One_File=1

let Tlist_Exit_OnlyWindow=1

let Tlist_Auto_Open=1

map :! ctags -R .

” NERDTree plugin

map :NERDTreeMirror

map :NERDTreeToggle

” au VimEnter * NERDTree

自动插入文件头

func SetFileTitle()

#如果文件类型为.sh文件

if &filetype == 'sh'

call setline(1,"\#########################################################################")

call append(line("."), "\# File Name: ".expand("%"))

call append(line(".")+1, "\# Author: ")

call append(line(".")+2, "\# mail:")

call append(line(".")+3, "\# Created Time: ".strftime("%c"))

call append(line(".")+4, "\#########################################################################")

call append(line(".")+5, "\#!/bin/bash")

call append(line(".")+6, "")

else

call setline(1, "/*************************************************************************")

call append(line("."), "    > File Name: ".expand("%"))

call append(line(".")+1, "    > Author: ")

call append(line(".")+2, "    > Mail: ")

call append(line(".")+3, "    > Created Time: ".strftime("%c"))

call append(line(".")+4, " ************************************************************************/")

call append(line(".")+5, "")

endif

#如果文件类型为.py文件

if &filetype == 'py'

call append(line(".")+6, "#!/usr/bin/env python")

call append(line(".")+7, "# -*- coding: utf-8 -*-")

endif

#如果文件类型为.php文件

if &filetype == 'php'

call append(line(".")+6, "<?php ")

endif

#如果文件类型为.html文件

if &filetype == 'html'

call append(line(".")+6, "")

call append(line(".")+7, "")

call append(line(".")+8, "

")

call append(line(".")+9, " ")

call append(line(".")+10, "

")

call append(line(".")+11, "")

call append(line(".")+12, "

")

call append(line(".")+13, "")

call append(line(".")+14, "")

endif

#如果文件类型为.c文件

if &filetype == 'c'

call append(line(".")+6, "#include")

call append(line(".")+7, "")

endif

#新建文件后,自动定位到文件末尾

autocmd BufNewFile * normal G

endfunc

快捷键

F4插入作者信息

map ms:call TitleDet()'s

function AddTitle()

call append(0,"/*******************************************************************************")

call append(1," * Author :")

call append(2," * Email : ")

call append(3," * Last modified : ".strftime("%Y-%m-%d %H:%M"))

call append(4," * Filename : ".expand("%:t"))

call append(5," * Description : ")

call append(6," * *****************************************************************************/")

echohl WarningMsg | echo "Successful in adding the copyright." | echohl None

endfunction

映射全选+复制 ctrl+a

map ggVGY

map! ggVGY

map gg=G

选中状态下 Ctrl+c 复制

vmap “+y

F2去空行

nnoremap :g/^\s*$/d

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值