自用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)
zerozero
上一篇 2017-04-24 20:25
下一篇 2017-04-24 20:40

相关推荐

  • haproxy 实战之haproxy实现httpd负载均衡

    haproxy 实战之haproxy实现httpd负载均衡 实验目的haproxy + httpd实现负载均衡 1.准备机器,做好时间同步,域名主机名解析 192.168.42.151 [node2 haproxy] 192.168.42.152 [node3 httpd] 192.168.42.153 [node4 httpd] 2.node3,node4…

    Linux干货 2017-06-29
  • 马哥教育网络班21期+第2周作业

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。     cp复制,mv移动,rm删除     1、cp:             1,用法: cp [OPTIO…

    Linux干货 2016-07-12
  • cp,chmod,chown,chgrg,grep命令应用实例和总结

    1.复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的其他属组和其他用户没有任何访问权限。[root@dxlcentOS ~]# cp -a /etc/skel/ /home/tuser1[root@dxlcentOS ~]# chmod -R go= /home/tuser1 递归修改权限,g:组的权限,o其他…

    Linux干货 2017-10-26
  • Redis 存储分片之代理服务Twemproxy 测试

    概述 实际业务场景中单点 Redis 容量、并发都是有限的,所以有 Redis Cluster 的需求。 但是官方的 Redis Cluster 一再跳票,还不可用。 只好先使用最简单的方式:Proxy。有很多可选,但在大范围生产使用的, Twitter 开源的 Twemproxy  看起来是个理想的选择 – https://…

    Linux干货 2015-03-10
  • httpd协议配置进阶

    目录 虚拟主机配置 status状态页面 curl命令 mod_deflate模块 https配置 httpd自带应用程序 虚拟主机配置 有三种实现方案:    基于IP:        为每个虚拟主机准备至少一个IP地址    基于端口:     &nbsp…

    Linux干货 2016-10-31
  • Linux终端类型

    Linux终端类型 关键字:linux终端,串行终端ttySn;伪终端pty;控制终端tty;控制台终端console 要想与Linux打交道,就必须学会使用Linux终端。所谓Linux终端,其实也就是一种控制台,一种字符设备,通常用tty标识,它是用户和Linux内核交互的平台,用户能在平台上通过各种指令操作Linux。终端的特殊设备文件一般分为以下几种…

    Linux干货 2016-10-19

评论列表(1条)

  • renjin
    renjin 2017-04-28 11:28

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