daiday

谨以此文记录下之前的折腾。(后续可能还会折腾什么)

目标

我的目的很简单,就是希望能有一个启动快速的文本编辑器,可以简单的代码着色,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,别人都装,我也象征性的安装了。我还设置了快捷键F10
    -Yggdroot/indentLine,可以给编辑器加上缩进线显示(2021/12/16)

颜色主题one-half

我很喜欢这个颜色主题。无论是深色还是浅色。
网址:https://github.com/sonph/onehalf
不过我个人只用colorscheme,并不是很喜欢airline什么的。所以我只是把colors文件夹里面的东西拷贝出来。。。

配置流程

我就是记录一下我自己的配置。要不换个电脑就又忘了。以后换个设备,步骤就是这样子的:

  1. 安装Mac Vim,或者gvim
  2. 安装vim-plug
  3. 找到one-half的主题,把vim/colors里面的两个主题偷走
  4. 直接覆盖掉下面的配置文件到.vimrc
  5. 确认自己是否安装了clang-format以及ctag
  6. 都安装完了?肯定还少个字体,去Google font里面找到roboto mono安装上吧
  7. 这次都折腾好了吧。运行PlugInstall吧。记得FQ头,稳一些。

(2021/12/16)Windows下,用gvim就可以。其实只要去掉工具栏以及滚动条,看上去也是可以很清爽的。稍微调整了一下文件配置。然而因为懒,所以没有合并起来。大体是差不多的。

(2021/12/16)我勤快了一下,合并了两个平台的.vimrc文件配置。

下面是.vimrc的内容:

" 到哪里都要用jj
inoremap jj <Esc>


" 缩进设置,行号设置等
set nu!  " 显示行号
set rnu! " 显示相对行号
set autoindent
set smartindent
set smarttab     " 根据文件自动判断tab大小
set expandtab    " tab扩展为空格
set tabstop=4    " tab大小
set shiftwidth=4 " 每一级锁进大小


" windows下设置文件编码
if has(\'win32\')
    set encoding=utf-8
    let &termencoding=&encoding
    set fileencodings=utf-8,gb18030,cp936,usc-bom,latin1
endif


" Change cursor shape between insert and normal mode in iTerm2.app
if $TERM_PROGRAM =~ "iTerm"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
    let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
    let &t_SR = "\<Esc>]50;CursorShape=2\x7" " Underline in replace mode
endif


" gvim下的表现效果
if has(\'gui_running\')
    set cursorline
    colorscheme onehalfdark
    if has(\'win32\')
        set guifont=Roboto\ Mono:h10
        set guifontwide=YouYuan:h10
        set guioptions=cm
    else
        setguifont=Roboto\ Mono:h13
    endif
endif


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin(\'~/.vim/plugged\')
Plug \'tpope/vim-sensible\'
Plug \'yianwillis/vimcdoc\'
Plug \'Yggdroot/indentLine\'
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(\':ClangFormat\')
    map <F3> :ClangFormat<CR>
endif
if exists(\':Tagbar\')
    map <F8> :TagbarToggle<CR>
endif
if exists(\':NERDTree\')
    map <F10> :NERDTreeToggle<CR>
endif

分类:

技术点:

相关文章: