自用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

相关推荐

  • N26-第二周

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。(盗图了,哈哈哈) 文件查看类命令:cat, tac, head, tail, more, less,touch    cat 查看文件内容   tac命令   反向查看文件内容  注:可对照上图 分屏查看命令:more  …

    Linux干货 2017-01-07
  • dd工具

    dd     dd命令:convert and copy a file     用法:        ddif=/PATH/FROM/SRC of=/PATH/TO/DEST       &…

    Linux干货 2016-09-02
  • 文件查找

    文件查找: locate查找:     locate:     依赖于事先构建好的索引库,操作系统刚完成没有       系统自动实现(周期性任务);      &nbs…

    Linux干货 2016-08-15
  • DNS-BIND

    1.实验环境 服务器类型 域名 IP 主DNS服务器 test.com. 192.5.24.101 从DNS服务器 192.5.24.102 子DNS服务器 ops.test.com. 192.5.24.201 备注:所有服务器需保持时间同步。 2.正向解析区域(192.5.24.101) 1)  安装bind 2)  编辑主配置文件,修…

    2017-05-31
  • Linux用户和组的相关管理命令(一、用户的相关命令)

    Linux是一个可以实现多用户登录的操作系统,通过su – 用户名 可以进行用户之间的切换,从而完成不同登录用户下对私有文件的操作,同时,每个用户有且只有一个主组,但是可以有零个或多个附加组,每个组可以是一个用户的主组,同时还可以是多个用户的附加组。因此,熟练掌握用户和组的相关命令十分重要。 首先,要了解用户和组的配置文件各有两个: 与用户相关的…

    2017-07-22
  • M20 – 1- 第三周博客(1):Linux用户、组

    Linux是个多用户多任务的分时操作系统,因此要使用系统资源的用户都必须先向系统管理员申请一个账号,然后以这个账号的身份进入系统。用户的账号一方面能帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问与限制,并为用户提供安全性保护。每个用户账号都拥有一个惟一的用户名(UID)和用户口令(PASSWD)。用户在登录时键入正确的用户名和口令后,才能…

    Linux干货 2016-08-04

评论列表(1条)

  • renjin
    renjin 2017-04-28 11:28

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