java vimrc_vimrc配置

" .vimrc

" Written by Matt Roper

"

" Feel free to use any or all of this file in your own vimrc file.

" Don't use vi compatibility; I want all the new features in Vim

set nocompatible

" Version 6.0-specific stuff

if version >= 600

syntax enable

filetype on

filetype plugin on

filetype indent on

else

syntax on

endif

set number

autocmd BufReadPost *

\ if line("'\"")>0&&line("'\"")<=line("$") |

\exe "normal g'\"" |

\ endif

" Low priority filename suffixes for filename completion {{{

set suffixes-=.h " Don't give .h low priority

set suffixes+=.aux

set suffixes+=.log

set wildignore+=*.dvi

set suffixes+=.bak

set suffixes+=~

set suffixes+=.swp

set suffixes+=.o

set suffixes+=.class

" }}}

set showfulltag " Get function usage help automatically

set showcmd " Show current vim command in status bar

set showmatch " Show matching parentheses/brackets

set showmode " Show current vim mode

set background=dark

set bs=2 " allow backspacing over everything in insert mode

set viminfo='20,\"50 " read/write a .viminfo file, don't store more

" than 50 lines of registers

set history=50 " keep 50 lines of command line history

set ruler " show the cursor position all the time

set nohlsearch " don't highlight search matches

set selection=exclusive " don't include character under cursor in selection

set incsearch " incremental (emacs-style) search

set vb t_vb= " kill the beeps! (visible bell)

set wildmenu " use a scrollable menu for filename completions

"set ignorecase " case-insensitive searching

" Indentation / tab replacement stuff

set shiftwidth=4 " > and < move block by 4 spaces in visual mode

set sts=4

set et " expand tabs to spaces

set autoindent " always set autoindenting on

" Move text, but keep highlight

vnoremap > >gv

vnoremap <

" Color Scheme (only if GUI running) {{{

if has("gui_running")

colorscheme evening

endif

" }}}

" Key mappings {{{

" Allow the . to execute once for each line in visual selection

vnoremap . :normal .

" Make ' function behave like ` usually does and then change ` to replay

" recorded macro a (as if @a was typed). In visual mode, ` (which now acts

" like @a) should function on all selected lines.

noremap ' `

nnoremap ` @a

vnoremap ` :normal @a

" Make tab perform keyword/tag completion if we're not following whitespace

inoremap =InsertTabWrapper()

" Make F7 spellcheck the buffer

noremap :call IspellCheck()

" Programming Keys:

" F9 = Make

" F10 = Next Error

" F11 = Prev Error

inoremap :make

inoremap :cnext

inoremap :cprev

noremap :make

noremap :cnext

noremap :cprev

" Buffer Switching:

" F2 = next buffer

" F3 = previous buffer

" F4 = kill buffer

inoremap :bn

inoremap :bp

inoremap :bd

noremap :bn

noremap :bp

noremap :bd

" Make p in Visual mode replace the selected text with the "" register.

vnoremap p :let current_reg = @"gvdi=current_reg

" Key mappings }}}

" Autocommands {{{

if has("autocmd")

" When vim is used in a console window, set the title bar to the

" name of the buffer being editted.

if !has("gui_running")

auto BufEnter * let &titlestring="VIM - ".expand("%:p")

endif

" In text and LaTeX files, always limit the width of text to 76

" characters. Also perform logical wrapping/indenting.

autocmd BufRead *.txt set tw=76 formatoptions=tcroqn2l

autocmd BufRead *.tex set tw=76

" Programming settings {{{

augroup prog

au!

au BufRead *.c,*.cc,*.cpp,*.h,*.java set formatoptions=croql cindent nowrap nofoldenable

au BufEnter *.java map :w\|:!javac %

au BufEnter *.c map :w\|:!gcc %

au BufEnter *.cc,*.cpp map :w\|:!g++ %

au BufLeave *.java,*.c,*.cc unmap

" Don't expand tabs to spaces in Makefiles

au BufEnter [Mm]akefile* set noet

au BufLeave [Mm]akefile* set et

" Set up folding for python

au FileType python set nofoldenable foldmethod=indent

augroup END

" }}}

" Reread configuration of Vim if .vimrc is saved {{{

augroup VimConfig

au!

autocmd BufWritePost ~/.vimrc so ~/.vimrc

autocmd BufWritePost vimrc so ~/.vimrc

augroup END

" }}}

" " C programming auto commands {{{

" augroup cprog

"

"

" " When starting to edit a file:

" " For C and C++ files set formatting of comments and set C-indenting on.

" " For other files switch it off.

" " Don't change the order, it's important that the line with * comes first.

" "autocmd FileType * set formatoptions=tcql nocindent comments&

" "autocmd FileType c,cpp set formatoptions=croql comments=sr:/*,mb:*,el:*/,://

"

" " Automatic "folding" in C code. This is cool.

" "if version >= 600

" " "au FileType c set foldenable foldmethod=indent

" " au FileType c,cpp set nofoldenable foldmethod=syntax

" " au FileType c,cpp syn region Block start="{" end="}" transparent fold

" " "au FileType c syn region Comment start="/\*" end="\*/" fold

" "endif

" augroup END

" " }}}

endif " has("autocmd")

" }}}

" Functions {{{

" IspellCheck() {{{

function! IspellCheck()

let l:tmpfile = tempname()

execute "normal:w!" . l:tmpfile . "\"

if has("gui_running")

execute "normal:!xterm -e ispell " . l:tmpfile . "\"

else

execute "normal:! ispell " . l:tmpfile . "\"

endif

execute "normal:%d\"

execute "normal:r " . l:tmpfile . "\"

execute "normal:1d\"

endfunction

" IspellCheck }}}

" InsertTabWrapper() {{{

" Tab completion of tags/keywords if not at the beginning of the

" line. Very slick.

function! InsertTabWrapper()

let col = col('.') - 1

if !col || getline('.')[col - 1] !~ '\k'

return "\"

else

return "\"

endif

endfunction

" InsertTabWrapper() }}}

" Functions }}}

" Settings for specific syntax files {{{

let c_gnu=1

let c_comment_strings=1

let c_space_errors=1

"let perl_fold=1 " turn on perl folding capabilities

" }}}

" Modeline {{{

" vim:set ts=4:

" vim600:fdm=marker fdl=0 fdc=3 vb t_vb=:

" }}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
YouCompleteMe是一个强大的自动补全插件,支持多种语言,如C/C++、Python、JavaScript等。下面是YouCompleteMe的安装配置过程: 1. 安装Vim插件管理器,如Vundle、Pathogen等。 2. 安装cmake工具,可以通过系统包管理器进行安装,如Ubuntu可以使用以下命令进行安装: ``` sudo apt-get install cmake ``` 3. 安装clang,可以通过系统包管理器进行安装,如Ubuntu可以使用以下命令进行安装: ``` sudo apt-get install clang ``` 4. 使用Vim插件管理器安装YouCompleteMe插件,可以在.vimrc文件中添加以下内容: ``` Plugin 'Valloric/YouCompleteMe' ``` 5. 编译YouCompleteMe插件,可以在.vimrc文件中添加以下内容: ``` " 编译YouCompleteMe插件 let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" let g:ycm_semantic_triggers = {'c': ['.'], 'cpp': ['.']} let g:ycm_autoclose_preview_window_after_completion = 1 let g:ycm_confirm_extra_conf = 0 let g:ycm_collect_identifiers_from_comments_and_strings = 1 let g:ycm_add_preview_to_completeopt = 1 let g:ycm_complete_in_comments = 1 let g:ycm_key_invoke_completion = '<C-Space>' let g:ycm_key_list_select_completion = '<Down>' let g:ycm_key_expand_or_complete = '<C-n>' let g:ycm_key_go_to_definition = '<C-]>' let g:ycm_key_go_to_declaration = '<C-t>' let g:ycm_filetype_blacklist = {} let g:ycm_filetype_specific_completion_to_disable = {} let g:ycm_min_num_of_chars_for_completion = 2 let g:ycm_collect_identifiers_from_tags_files = 1 let g:ycm_cache_omnifunc = 1 let g:ycm_seed_identifiers_with_syntax = 1 let g:ycm_server_keep_logfiles = 0 let g:ycm_server_log_level = 0 let g:ycm_server_python_interpreter = 'python3' let g:ycm_use_ultisnips_completer = 1 let g:ycm_python_binary_path = 'python3' " 编译YouCompleteMe插件 function! BuildYCM(info) " 定义编译命令 let cmd = ['python3', '~/.vim/bundle/YouCompleteMe/install.py', '--clang-completer'] " 执行编译命令 call system(join(cmd, ' ')) endfunction " 自动编译YouCompleteMe插件 let g:ycm_auto_trigger = 1 let g:ycm_auto_trigger_delay = 2000 let g:ycm_auto_trigger_threshold = 1 autocmd FileType c,cpp,python,go,java,javascript,typescript,php,html,css,scss,xml,markdown call BuildYCM({}) ``` 然后在Vim中执行以下命令进行插件安装和编译: ``` :PluginInstall :call BuildYCM({}) ``` 编译成功后,YouCompleteMe插件就可以正常使用了。 以上就是YouCompleteMe的安装配置过程,希望对你有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值