美文网首页
Vim 编辑器应用

Vim 编辑器应用

作者: easy_book | 来源:发表于2016-11-24 13:19 被阅读0次

    编辑器设置:

    • syntax on 语法高亮
    • set number 显示行号
    • set autoindent set cindent 自动缩进
    • 自动加入文件头:
      autocmd BufNewFile .py,.cpp,.sh,.java exec ":call SetTitle()"
      func SetTitle()
      if &filetype == 'sh'
      call setline(1,"#!/bin/bash")
      call append(line("."), "# Author:Byrd")
      call append(line(".")+1, "# Version:0.1")
      call append(line(".")+2, "# Site:www.t4x.org")
      call append(line(".")+3, "# Contact:root#t4x.org")
      call append(line(".")+4, "")
      elseif &filetype == 'cpp'
      call setline(1,"// File Name: ".expand("%"))
      call append(line("."), "// Author: Byrd")
      call append(line(".")+1, "// Created Time: ".strftime("%c"))
      call append(line(".")+2, "")
      call append(line(".")+3, "#include<iostream>")
      call append(line(".")+4, "#include<string>")
      call append(line(".")+5, "#include<algorithm>")
      call append(line(".")+6, "#include<cstdlib>")
      call append(line(".")+7, "using namespace std;")
      call append(line(".")+8, "int main(){")
      call append(line(".")+9, "")
      call append(line(".")+10, " return 0")
      call append(line(".")+11,"}")
      elseif &filetype == 'python'
      call setline(1,"#!/usr/bin/env python")
      call append(line("."), "# Author: Byrd")
      call append(line(".")+1, "# Created Time: ".strftime("%c"))
      call append(line(".")+2, "")
      else
      call setline(1,"/")
      call append(line("."), "
      Author: Byrd")
      call append(line(".")+1, "* Created Time: ".strftime("%c"))
      call append(line(".")+2, "*/")
      call append(line(".")+3, "")
      endif
      endfunc
    "新建文件后,自动定位到文件末尾
    autocmd BufNewFile * normal G
    "ts是tabstop的缩写,设TAB宽4个空格
    

    set ts=4
    set expandtab

    相关文章

      网友评论

          本文标题:Vim 编辑器应用

          本文链接:https://www.haomeiwen.com/subject/ytebpttx.html