IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> .vimrc参考 -> 正文阅读

[开发工具].vimrc参考

.vimrc参考示例

贴一份本人的.vimrc参考,放在home目录下(~),并重命名为.vimrc,然后打开vim,执行如下指令即可安装:

:PlugInstall

说明:

  • leader键为;(小拇指按很方便~)
  • YouCompleteMe自然是必须的啦
  • airline
  • molokai主题
  • 带注释
  • nerdtree
  • nerdcommenter
  • auto-pair
  • 窗口跳转快捷键

具体如下:

set nocompatible              " be iMproved, required
set backspace=indent,eol,start
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
"Plugin 'vim-airline/vim-airline'
"Plugin 'vim-airline/vim-airline-themes'
Plugin 'jiangmiao/auto-pairs'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
"Plugin 'flazz/vim-colorschemes'
"Plugin 'altercation/vim-colors-solarized'
Plugin 'Yggdroot/LeaderF'
Plugin 'majutsushi/tagbar'
"Plugin 'airblade/vim-gitgutter'
"Plugin 'tpope/vim-fugitive'
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

let mapleader=";"                    "将';'设置为leader
set nu

"filetype on                     "检测文件类型
"filetype indent on              "为特定文件类型载入相关缩进文件

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-b> :bp<CR>
nnoremap <C-n> :bn<CR>

" code
set mouse=a
"set tw=4 this line will make shell auto enter...
set et
set smarttab
"set encoding=utf-8
set tabstop=4
set shiftwidth=4
set autoindent
set expandtab

" syntax
syntax enable

" search
set incsearch
set hlsearch
set ic "ignore case

" code jump
nnoremap <F7> <ESC><ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>
set tags=tags;/
set tags+=./tags "add current directory's generated tags file
set tags+=tags,/usr/include/tags,~/.
set cscopequickfix=s-,c-,d-,i-,t-,e-        "使用quickfix显示cscope的结果

" theme
syntax on
syntax enable
set t_Co=256
set background=dark
colorscheme molokai

 "file
au BufRead,BufNewFile *.{sh}   set filetype=sh
au BufRead,BufNewFile *.{c}    set filetype=c
au BufRead,BufNewFILE *.{py}   set filetype=python
au BufRead,BufNewFILE *.{java} set filetype=java
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}   set filetype=mkd
au BufRead,BufNewFile *.{go}   set filetype=go
au BufRead,BufNewFile *.{js}   set filetype=javascript
au BufRead,BufNewFile *.{log}  set filetype=log

autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py exec ":call SetTitle()" 
func SetTitle() 
    if &filetype == 'sh' 
        call setline(1, "\###############################################################") 
        call append(line(".")+0, " \# Copyright(c) 2005-".strftime("%Y")." Shenzhen xxxxxx Technologies Co. Ltd.") 
        call append(line(".")+1, " \# All right reserved.") 
        call append(line(".")+2, " \#") 
        call append(line(".")+3, " \# Filename		:	".expand("%")) 
        call append(line(".")+4, " \# Version		:	1.0") 
        call append(line(".")+5, " \# Abstract		:	") 
        call append(line(".")+6, " \# Author		:	xxxxxx(xxxxxxx)") 
        call append(line(".")+7, " \# Created Date	:	".strftime("%Y.%m.%d")) 
        call append(line(".")+8, " \#") 
        call append(line(".")+9, " \# Modified History:") 
        call append(line(".")+10, " \# 1.Create file.	".strftime("%Y.%m.%d")."  Cyril Zheng") 
        call append(line(".")+11, "\###############################################################") 
        call append(line(".")+12, "\#!/bin/bash") 
    elseif &filetype == 'python'
        call setline(1,"#!/usr/bin/env python3")
        call append(line(".")+0,"# -*- coding: UTF-8 -*-")
        call append(line(".")+1,"")
        call append(line(".")+2,"def main():")
        call append(line(".")+3,"    print(\"hello world\")")
        call append(line(".")+4,"")
        call append(line(".")+5,"if __name__ == \"__main__\":")
        call append(line(".")+6,"    main()")
	else 
        call setline(1, "/***************************************************************") 
        call append(line(".")+0, " * Copyright(c) 2005-".strftime("%Y")." ") 
        call append(line(".")+1, " * All right reserved.") 
        call append(line(".")+2, " *") 
        call append(line(".")+3, " * Filename		:	".expand("%")) 
        call append(line(".")+4, " * Version		:	1.0") 
        call append(line(".")+5, " * Abstract		:	") 
        call append(line(".")+6, " * Author		:	xxxx") 
        call append(line(".")+7, " * Created Date	:	".strftime("%Y.%m.%d")) 
        call append(line(".")+8, " *") 
        call append(line(".")+9, " * Modified History:") 
        call append(line(".")+10, " * 1.Create file.	".strftime("%Y.%m.%d")."  xxxx") 
        call append(line(".")+11, " ***************************************************************/") 
        call append(line(".")+12, "") 
    endif

	if expand("%:e") == 'cpp'
        call append(line(".")+13, "#include <iostream>")
        call append(line(".")+14, "using namespace std;")
        call append(line(".")+15, "")
		call append(line(".")+16, "int main(int argc, char const *argv[])")
        call append(line(".")+17, "{")
        call append(line(".")+18, "	return 0;")
        call append(line(".")+19, "}")
    endif

    if &filetype == 'c'
        call append(line(".")+13, "#include <stdio.h>")
        call append(line(".")+14, "#include <stdlib.h>")
        call append(line(".")+15, "#include <string.h>")
        call append(line(".")+16, "#include <stdbool.h>")
        call append(line(".")+17, "")
        call append(line(".")+18, "#define print(fmt, args...) printf(\"\\033[1m[ \%s ] \%03d\: \"fmt\"\\033\[0m\\n\\r\", __FUNCTION__, __LINE__, ##args)")
        call append(line(".")+19, "")
		call append(line(".")+20, "int main(int argc, char const *argv[])")
        call append(line(".")+21, "{")
        call append(line(".")+22, "	return 0;")
        call append(line(".")+23, "}")
	endif

	if expand("%:e") == 'h'
		call append(line(".")+13, "#ifndef _".toupper(expand("%:t:r"))."_H_")
		call append(line(".")+14, "#define _".toupper(expand("%:t:r"))."_H_")
		call append(line(".")+15, "")
		call append(line(".")+16, "")
		call append(line(".")+17, "")
		call append(line(".")+18, "#endif")
	endif

	if &filetype == 'java'
		call append(line(".")+13,"public class ".expand("%:t:r")." {")
		call append(line(".")+14,"	public static void main(String[] args) {")
		call append(line(".")+15,"	}")
		call append(line(".")+16,"}")
	endif
endfunc 
autocmd BufNewFile * normal G

autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2 
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1

"nerdtree
nnoremap <silent> <F3> :NERDTreeToggle<CR>

" tagbar
let g:tagbar_width=35
let g:tagbar_autofocus=0
nmap <F6> :TagbarToggle<CR>

" LeaderF
let g:Lf_ShortcutB='<leader>b'
let g:Lf_DefaultMode='NameOnly'
let g:Lf_CursorBlink=0
let g:Lf_HideHelp=1
let g:Lf_ShowHidden=1
let g:Lf_ShowDevIcons=0
noremap <Leader>s :<C-U><C-R>=printf("Leaderf! rg -e \"%s\"", expand("<cword>"))<CR>
let g:Lf_PreviewInPopup = 1
let g:Lf_WindowPosition = 'popup'
"let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b3", 'font': "DejaVu Sans Mono for Powerline" }
let g:Lf_StlSeparator = { 'left': '', 'right': '' }
let g:Lf_PreviewResult = {'Function': 1, 'BufTag': 0 }
let g:Lf_ShowDevIcons = 1
let g:Lf_ShortcutF = "<leader>ff"
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>

"ycm
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 0
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_show_diagnostics_ui = 0

let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'
let g:ycm_use_clangd = 1
let g:ycm_clangd_binary_path = "/usr/bin/clangd"
let g:ycm_clangd_uses_ycmd_caching = 1
let g:ycm_add_preview_to_completeopt = 0

"AutoPairsFlyMode
let g:AutoPairsFlyMode = 0

let NERDTreeIgnore=['.*\.pyc$','.*\.o$','.*\.ko$']  " 忽略.pyc .o .ko 结尾的文件
"fonts
let laststatus = 2
let g:airline_powerline_fonts = 1   "use fonts that powerline has patched
let g:Powerline_symbols='fancy'

创建c文件示例如下:

 *
 * Modified History:
 * 1.Create file.	2021.08.09  xxxx
 ***************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define print(fmt, args...) printf("\033[1m[ %s ] %03d: "fmt"\033[0m\n\r", __FUNCTION__, __LINE__, ##args)

int main(int argc, char const *argv[])
{
	return 0;
}

主题如下:
在这里插入图片描述

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2021-08-10 13:38:21  更:2021-08-10 13:38:27 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/20 15:21:18-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码