我的vim配置相關
謹以此文記錄下之前的折騰。(后續可能還會折騰什么)
目標
我的目的很簡單,就是希望能有一個啟動快速的文本編輯器,可以簡單的代碼著色,vim鍵位,簡單的文本修改,打開大點的文件不發愁,可以簡單的format一些文件格式等等。所以,windows下我就是用gvim,mac下我用Mac Vim。沒錯,gui為主。不咋用tui。
Neovim
我已經不用這個了,因為并非重度vim用戶,根本用不出區別來。什么job啊,什么luajit啊,什么完整的terminal內核啊,什么獨立進程嵌入到其他應用中啊。雨我無瓜。
配置&插件
下面的配置基本上都是要在一個vim-plug插件的基礎上進行的。沒這個,我還真沒法繼續折騰。
安裝vim-plug
Unix&Linux
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
You can automate the process by putting the command in your Vim configuration file as suggested here.
Windows (PowerShell)
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni $HOME/vimfiles/autoload/plug.vim -Force
插件推薦
tpope/vim-sensible,大家都用的vim的默認配置。雖然我仍然又加了一些內容。。。不過還好還好。yianwillis/vimcdoc,vim的中文文檔。我英文不好,看看中文的有助于提高(嘴硬octol/vim-cpp-enhanced-highlight,強化cpp的語法著色。挺不錯的。rhysd/vim-clang-format,vim的indent怎么也不如clang-format好用,是不是?我設置成了F3(看別人都這么搞)preservim/tagbar,可以顯示大綱視圖之類的,挺好用的。需要自己安裝一下ctag。brew或者scoop一下。我還設置了F8的快捷鍵(人家推薦的preservim/nerdtree,別人都裝,我也象征性的安裝了。我還設置了快捷鍵F10Yggdroot/indentLine,可以給編輯器加上縮進線顯示(2021/12/16)tpope/vim-surround,最近發現還是很需要這個插件的,能省不少事(2022/09/28)easymotion/vim-easymotion,用了一下,跳轉的還是很不錯。idea也有,先安裝AceJump再安裝idea-easymotion(2022/09/28)
顏色主題one-half
我很喜歡這個顏色主題。無論是深色還是淺色。
網址:https://github.com/sonph/onehalf
不過我個人只用colorscheme,并不是很喜歡airline什么的。所以我只是把colors文件夾里面的東西拷貝出來。。。
配置流程
我就是記錄一下我自己的配置。要不換個電腦就又忘了。以后換個設備,步驟就是這樣子的:
- 安裝
Mac Vim,或者gvim - 安裝
vim-plug - 找到
one-half的主題,把vim/colors里面的兩個主題偷走 - 直接覆蓋掉下面的配置文件到
.vimrc - 確認自己是否安裝了
clang-format以及ctag - 都安裝完了?肯定還少個字體,去Google font里面找到
roboto mono安裝上吧 - 這次都折騰好了吧。運行
PlugInstall吧。記得FQ頭,穩一些。 - 重新設置了一下
leader鍵,映射到了空格鍵:let mapleader=" ",并且加了一些復制粘貼的快捷鍵。
(2021/12/16)Windows下,用gvim就可以。其實只要去掉工具欄(以及滾動條 我后來保留垂直滾動條了22/09/28),看上去也是可以很清爽的。稍微調整了一下文件配置。然而因為懶,所以沒有合并起來。大體是差不多的。
(2021/12/16)我勤快了一下,合并了兩個平臺的.vimrc文件配置。
下面是.vimrc的內容:
" 到哪里都要用jj
inoremap jj <Esc>
" 簡單的leader快捷映射,強化復制粘貼
let mapleader=" "
" copy and paste
noremap <leader>y "zy
noremap <leader>Y "zY
noremap <leader>p "zp
noremap <leader>P "zP
" windows下設置文件編碼
set encoding=utf-8
let &termencoding=&encoding
set fileencodings=utf-8,gb18030,cp936,usc-bom,latin1
set cursorline
set guifont=Roboto\ Mono:h10
set guifontwide=YouYuan:h10
set guioptions=cm
set winaltkeys=yes
if has('gui_running')
colorscheme onehalflight
set go+='r' " 總是顯示右邊的滾動條
endif
set nu! " 顯示行號
set rnu! " 顯示相對行號
set autoindent
set smartindent
set smartcase " 智能大小寫搜索
set smarttab " 根據文件自動判斷tab大小
set expandtab " tab擴展為空格
set tabstop=4 " tab大小
set shiftwidth=4 " 每一級鎖進大小
" Change cursor shape between insert and normal mode in iTerm2.app
"if $TERM_PROGRAM =~ "iTerm"
" let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
" let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
"endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
Plug 'yianwillis/vimcdoc'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'easymotion/vim-easymotion'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'rhysd/vim-clang-format', {'on': 'ClangFormat'}
Plug 'preservim/tagbar', {'on': 'TagbarToggle'}
Plug 'preservim/nerdtree', {'on': 'NERDTreeToggle'}
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if exists(':Tagbar')
map <F8> :TagbarToggle<CR>
endif
if exists(':NERDTree')
map <F10> :NERDTreeToggle<CR>
endif
if exists(':ClangFormat')
map <F3> :ClangFormat<CR>
endif

浙公網安備 33010602011771號