首页 > 其他分享 >Vim之.vimrc配置

Vim之.vimrc配置

时间:2024-01-19 11:00:14浏览次数:23  
标签:set vimrc 配置 Vim call ycm let line append

共享一份.vimrc配置文件。

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

"syntax enable
"set background=dark
"colorscheme solarized
"let g:solarized_termcolors=256
"let g:solarized_termtrans = 1
"let g:solarized_diffmode = "normal"
"let g:solarized_use16 = 1

 "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")." TriHappy 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		:	Adam Ma") 
        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")."  Adam Ma") 
        call append(line(".")+11, "\###############################################################") 
        call append(line(".")+12, "\#!/bin/sh") 
    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")." TriHappy 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		:	Adam Ma") 
        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")."  Adam Ma") 
        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>
nnoremap <leader>j :%!python -m json.tool<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'

标签:set,vimrc,配置,Vim,call,ycm,let,line,append
From: https://www.cnblogs.com/adam-ma/p/17974182

相关文章

  • dremio 基于Options注解的配置技巧
    以前简单写过一个dremio配置相关的介绍,以下是一个简单的使用原理dremio自己定义了一个Options的注解,包含此注解的类会被启动的时候进行类扫描加载,Options的会存储起来(分为不用类型的)有session级别的,系统级别的。。。。简单使用pom.xml <?xmlversion="1.......
  • openEuler欧拉配置MySQL8的MGR单主双从
    一、系统优化(三个节点全部操作)关闭防火墙systemctlstopfirewalldsystemctldisablefirewalld关闭selinuxecho"SELINUX=disabled">/etc/selinux/configecho"SELINUXTYPE=targeted">>/etc/selinux/configcat/etc/selinux/configsetenforce0设置主机名hostn......
  • Nginx配置反向代理实例及Keepalived主从切换
    概述工作中经常需要帮同事配置反向代理,反向代理的使用场景一般为办公网跨网访问生产网应用资源。今天简单记录下操作步骤,以备之后查阅。NGX配置nginx的配置一般放置在/etc/nginx/nginx.conf下,可以使用whereisnginx查看nginx的具体位置[root@NGXapp01~]#whereisnginxngi......
  • Nginx基础配置详解(main、events、http、server、location)
    Nginx基础配置详解(main、events、http、server、location):https://blog.csdn.net/weixin_43834401/article/details/130562289?ops_request_misc=&request_id=&biz_id=102&utm_term=nginx%20server%20%E7%9A%84%E6%A0%B9%E7%9B%AE%E5%BD%95&utm_medium=distribute.pc_......
  • MybatisPlus集成baomidou-dynamic,多数据源配置使用、MybatisPlus分页分组等操作示例
    MybatisPlus特性无侵入:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑损耗小:启动即会自动注入基本CURD,性能基本无损耗,直接面向对象操作强大的CRUD操作:内置通用Mapper、通用Service,仅仅通过少量配置即可实现单表大部分CRUD操作,更有强大的条件构造器,满足各类使用......
  • SkyWalking服务监控简单配置【Windows版本】
    SkyWalking是什么skywalking是一个可观测性分析平台和应用性能管理系统专为微服务、云原生架构和基于容器(Docker、K8s、Mesos)架构而设计。下载官网:https://skywalking.apache.org/下载地址:https://skywalking.apache.org/downloads/中文文档:https://skyapm.github.io/doc......
  • Linux配置静态ip以及有线连接配置
    设置静态ip1.首先选择VMware打开编辑中的虚拟网络编辑器2.给net8配置网管然后确定3.找到网络设置更改IPV4ip网络设置配置静态ip后servicenetworkrestart失败重启网络:systemctlstartnetwork.service2、配置文件无问题还有报错,启动以下命令$systemctlstopNet......
  • kaggle上的jax框架的环境配置(TPU版本)
    导出时间:2024-01-1821:00:37星期四python版本:Python3.10.13absl-py==1.4.0accelerate==0.25.0aiofiles==22.1.0aiosqlite==0.19.0anyio==4.2.0argon2-cffi==23.1.0argon2-cffi-bindings==21.2.0array-record==0.5.0arrow==1.3.0astroid==3.0.2asttokens==2.4......
  • aws 服务器 ssh 通过密码连接配置
    背景通过信用卡薅了一年aws服务器的羊毛,1cpu30g固态硬盘,默认服务器不允许root用户使用密码进行ssh连接,因此需要以下的步骤通过密码远程ssh连接到服务器。步骤使用AWS控制台进行网页登录创建root密码sudopasswdroot切换到root用户suroot修改sshd_co......
  • Linux网卡配置文件解析
    [root@localhost130~]#cat/etc/sysconfig/network-scripts/ifcfg-ens33TYPE="Ethernet"#网络类型为以太网#PROXY_METHOD="none"#代理方式#BROWSER_ONLY="no"#只是浏览器:否BOOTPROTO="static"#网卡协议获取网卡ip的方式,dhcp动态主机配置协议也就是自动获取,no......