基本顯示設置
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
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
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.www58058.com/74119
對vim編輯器進行了詳細的介紹,內容寫的很詳細,排版也很好,加油!