效果 今天介绍一下vim的别一个非常好用的插件,启动界面插件 vim-startify。 这个插件有什么用呢,看效果:
中间是最近打开的文件,可能通过数字快数打开文件,界面可以设置找开和关闭。
安装配置 1.vim插件安装 1 2 3 call plug#begin('~/.vim/plugged' )Plug 'mhinz/vim-startify' call plug#end()
2.配置 配置不是必须项目,当然一般情况下,都会习惯自己一的快捷键。 另外书签功能是个很好用的功能,把常用的文件直接加入书签,如果书签加入是个目录,也安装了ranger 插件,可以直接调用 ranger 这个插件。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 let g:startify_bookmarks = [ \ '~/workspaces/' , \ '~/.config/nvim/init.vim' , \] let g:startify_files_number = 10 let g:startify_session_autoload = 1 let g:startify_skiplist = [ \ '^/tmp' , \ ] let g:startify_custom_header = [ \ '+------------------------------+' , \ '| |' , \ '| Still waters run deep! |' , \ '| |' , \ '+----------------+-------------+' , \] let g:startify_custom_footer = [ \ '+------------------------------+' , \ '| Keep an open mind! |' , \ '+----------------+-------------+' , \] function ! SomeCheck () if filereadable (expand ("%" )) echo "SpecificFile exists" else autocmd VimEnter * Startify endif endfunction call SomeCheck()
脚本中的代码部分是解决,在不同位置启动后,找不到文件时会报错 function! endfunction 固定一对
内置函数,% 表示当前路径,也表示当前文件路径 expand("%") call 执行函数
可以自行偿试注释掉脚本部份复现问题。
到这一步vim的IDE进行启动界面就完成了,通过这些插件提高平时写文档的效率是够用的。
书签功能 官方文档 github https://github.com/mhinz/vim-startify
帮助
:h startify :h startify-faq
完整配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 set fileencodings=utf-8 ,gb2312,gb18030,gbk,ucs-bom,cp936,latin1set enc=utf8set fencs=utf8,gbk,gb2312,gb18030set nocompatiblefiletype on filetype plugin indent on set tabstop=4 set shiftwidth =4 set softtabstop=4 set expandtabset cursorcolumnau BufReadPost * if line ("'\"" ) > 1 && line ("'\"" ) <= line ("$" ) | exe "normal! g'\"" | endif map td :set splitright<CR> :vsplit <CR> map ta :set nosplitright<CR> :vsplit <CR> map ts :set nosplitbelow<CR> :split <CR> map tw :set splitbelow<CR> :split <CR> map <M-up> :res -5 <CR> map <M-down> :res +5 <CR> map <M-left> :vertical resize -5 <CR> map <M-right> :vertical resize +5 <CR> map W :w <CR> map Q :wq <CR> map tq :q!<CR> map te :terminal<CR> set list listchars=extend s: ❯,precedes: ❮,ta b: ▸\syntax on set number "set relativenumber " 相对行号set wildmenu set hlsearch set incsearch set t_ut= vnoremap <C-y> nnoremap <C-p> call plug#begin('~/.vim/plugged' )Plug 'scrooloose/nerdtree' Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'mhinz/vim-startify' call plug#end()map tt :NERDTreeToggle<CR> autocmd vimenter * NERDTreemap <leader> r :NERDTreeFind<cr> <C-w> <C-w> "显示书签" let NERDTreeShowBookmarks=1 let NERDTreeShowHidden=1 let NERDTreeIgnore=['\.pyc' ,'\~$' ,'\.swp' ]let g:NERDTreeGitStatusIndicatorMapCustom = { \ "Modified" : "✹" , \ "Staged" : "✚" , \ "Untracked" : "✭" , \ "Renamed" : "➜" , \ "Unmerged" : "═" , \ "Deleted" : "✖" , \ "Dirty" : "✗" , \ "Clean" : "✔︎" , \ 'Ignored' : '☒' , \ "Unknown" : "?" \ } let g:startify_bookmarks = [ \ '~/workspaces/' , \ '~/.config/nvim/init.vim' , \] let g:startify_files_number = 10 let g:startify_session_autoload = 1 let g:startify_skiplist = [ \ '^/tmp' , \ ] let g:startify_custom_header = [ \ '+------------------------------+' , \ '| |' , \ '| Still waters run deep! |' , \ '| |' , \ '+----------------+-------------+' , \] let g:startify_custom_footer = [ \ '+------------------------------+' , \ '| Keep an open mind! |' , \ '+----------------+-------------+' , \] function ! SomeCheck () if filereadable (expand ("%" )) echo "SpecificFile exists" else autocmd VimEnter * Startify endif endfunction call SomeCheck()