自用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, "<!DOCTYPE HTML>")
        call append(line(".")+7, "<html lang="en-US">")
        call append(line(".")+8, "<head>")
        call append(line(".")+9, "  <meta charset="UTF-8">")
        call append(line(".")+10, " <title></title>")
        call append(line(".")+11, "</head>")
        call append(line(".")+12, "<body>")
        call append(line(".")+13, "</body>")
        call append(line(".")+14, "</html>")
    endif
#如果文件类型为.c文件
    if &filetype == 'c'
        call append(line(".")+6, "#include<stdio.h>")
        call append(line(".")+7, "")
    endif
#新建文件后,自动定位到文件末尾
    autocmd BufNewFile * normal G
endfunc 

快捷键

F4插入作者信息

map <F4> ms:call TitleDet()<cr>'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

原创文章,作者:zero,如若转载,请注明出处:http://www.178linux.com/74119

(0)
上一篇 2017-04-24 20:25
下一篇 2017-04-24 20:40

相关推荐

  • shell脚本中变量与运算及简单编程示例

    一、变量         在Linux shell脚本的变量中,分为系统定义的变量和用户定义的变量。这些变量是用来调用一个数值或字符值。定义变量时,不需要声明变量类型。 1、系统变量         …

    Linux干货 2016-08-15
  • 马哥教育21期网络班—第五周课程+练习

    1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; grep "^[[:space:]]\+" /boot/grub/grub.conf 2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行; grep "…

    Linux干货 2016-07-29
  • 磁盘配额、阵列与逻辑卷

    一、磁盘配额 在内核中执行以文件系统为单位启用对不同组或者用户的策略不同 根据块或者节点进行限制执行软限制(soft limit)硬限制(hard limit) 步骤一:获得文件系统支持临时有效:mount -o remount,usrquota,grpquota {mount_point|device}永久有效:写入配置文件 /etc/fstab 中检查文…

    Linux干货 2016-08-29
  • 解决CentOS SSH 连接慢

    1、关闭DNS反向解析在linux中,默认就是开启了SSH的反向DNS解析,这个会消耗大量时间,因此需要关闭。配置文件路径 vim /etc/ssh/sshd_configUseDNS=no 在配置文件中,虽然UseDNS yes是被注释的,但默认开关就是yes 2、关闭SERVER上的GSS认证在authentication gssapi-with-mic…

    Linux干货 2018-01-10
  • MongoDB复制集及数据分片详解

    前言 MongoDB是一个由C++语言编写的基于分布式文件存储的数据库,是当前NoSQL数据库中比较热门的一种,旨在为Web应用提供可扩展的高性能数据存储解决方案。本文介绍MongoDB复制集及数据分片。 MongoDB 简介 MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。支持的数据结构非常松散,…

    Linux干货 2015-07-15

评论列表(1条)

  • renjin
    renjin 2017-04-28 11:28

    对vim编辑器进行了详细的介绍,内容写的很详细,排版也很好,加油!