【Linux配置】vim配置文件内容

  • vim的配置
  • 文件:~/.vimrc
  • 在自己的家目录中的.vimrc文件进行编辑配置
  • 设置如下:
  •  1 set nu  "序号
     2 set tabstop=4  "tab键的大小
     3 set showcmd     
     4 nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR>   "用F2开关数字,方便复制
     5 
     6 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
     7 "新建.c,.h,.sh,.java文件,自动插入文件头 
     8 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 
     9 ""定义函数SetTitle,自动插入文件头 
    10 func SetTitle() 
    11     "如果文件类型为.sh文件 
    12     if &filetype == sh 
    13         call setline(1,"\#########################################################################") 
    14         call append(line("."), "\# File Name: ".expand("%")) 
    15         call append(line(".")+1, "\#Copyright@ Author:Panhao_Neo ") "这里是版权名(作者)
    16         call append(line(".")+2, "\# mail: [email protected]")      "邮箱
    17         call append(line(".")+3, "\# Created Time: ".strftime("%c"))
    18         call append(line(".")+4, "\#########################################################################")
    19         call append(line(".")+5, "\#!/bin/bash")
    20         call append(line(".")+6, "")
    21     else
    22         call setline(1, "/*************************************************************************")
    23         call append(line("."), "    > File Name: ".expand("%"))
    24         call append(line(".")+1, "  > Copyright@ Author:Panhao_Neo ")  
    25         call append(line(".")+2, "  > Mail: [email protected] ")
    26         call append(line(".")+3, "  > Created Time: ".strftime("%c"))
    27         call append(line(".")+4, " ************************************************************************/")
    28         call append(line(".")+5, "")
    29     endif
    30     if &filetype == cpp
    31         call append(line(".")+6, "#include<iostream>")
    32         call append(line(".")+7, "using namespace std;")
    33         call append(line(".")+8, "")
    34  endif
    35     if &filetype == c
    36         call append(line(".")+6, "#include<stdio.h>")
    37         call append(line(".")+7, "int main()")
    38         call append(line(".")+8, "{")
    39         call append(line(".")+9, "    ")
    40         call append(line(".")+10, "}")
    41     endif
    42     "   if &filetype == ‘java‘
    43     "       call append(line(".")+6,"public class ".expand("%"))
    44     "       call append(line(".")+7,"")
    45     "   endif
    46     "新建文件后,自动定位到文件末尾
    47     autocmd BufNewFile * normal G
    48 endfunc

     

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。