- 第一步
安装nvim,下载地址:http://neovim.io/。 - 第二步
配置plug-vim,下载plug.vim文件(https://github.com/junegunn/vim-plug),将文件复制到~/AppData/Local/nvim-data/site/autoload文件夹下。 - 第三步
编写nvim配置文件init.vim,将文件复制到~/AppData/Local/nvim文件夹下,配置文件如下:
" 基础配置
syntax on
" 设置状态行显示常用信息
" %F 完整文件路径名
" %m 当前缓冲被修改标记
" %m 当前缓冲只读标记
" %h 帮助缓冲标记
" %w 预览缓冲标记
" %Y 文件类型
" %b ASCII值
" %B 十六进制值
" %l 行数
" %v 列数
" %p 当前行数占总行数的的百分比
" %L 总行数
" %{...} 评估表达式的值,并用值代替
" %{"[fenc=".(&fenc==""?&enc:&fenc).((exists("+bomb") && &bomb)?"+":"")."]"} 显示文件编码
" %{&ff} 显示文件类型
set statusline=%F%m%r%h%w%=\ [%{&ff}]\ %{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\"+\":\"\").\"]\"}\ [%L]\ [%v,%l]\ [%p%%]
" 设置 laststatus = 0 ,不显式状态行
" 设置 laststatus = 1 ,仅当窗口多于一个时,显示状态行
" 设置 laststatus = 2 ,总是显式状态行
set laststatus=2
set t_Co=256
" set virtualedit=all
" set clipboard=unnamedplus
set autochdir
set nobackup
set guifont=consolas:h11
set fileencodings=utf-8,gbk
set fileencoding=utf-8
set termencoding=utf-8
set encoding=utf-8
set number
set relativenumber
set list
set cursorline
" set foldenable
" set foldmethod=indent
set noexpandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set scrolloff=4
set notimeout
set ttimeoutlen=0
set wrap
set splitright
set splitbelow
set showmatch
set showcmd
set wildmenu
set ignorecase
set smartcase
set termguicolors
set winaltkeys=no
set hidden
set showcmd
set nowrapscan
" 插件
call plug#begin('~\AppData\Local\nvim-data\site\plugged')
" themes
Plug 'morhetz/gruvbox'
" Markdown
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle', 'for': ['text', 'markdown', 'vim-plug'] }
Plug 'mzlogin/vim-markdown-toc', { 'for': ['gitignore', 'markdown', 'vim-plug'] }
" vim-airline
" Plug 'vim-airline/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
" fzf
" Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Plug 'junegunn/fzf.vim'
" nerdtree
" Plug 'preservim/nerdtree'
" gitgutter
" Plug 'airblade/vim-gitgutter'
call plug#end()
" ===================== Start of Plugin Settings =====================
" themes
colorscheme gruvbox
" nerdtree
" 浏览指定文件夹 Nredtree path
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
" \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
" 关闭vim,如果只剩Ntree窗口
" autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" markdown-preview
let g:mkdp_open_to_the_world=1
let g:mkdp_open_ip='localhost'
" vim-table-mode
function! s:isAtStartOfLine(mapping)
let text_before_cursor = getline('.')[0 : col('.')-1]
let mapping_pattern = '\V' . escape(a:mapping, '\')
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
endfunction
inoreabbrev <expr> <bar><bar>
\ <SID>isAtStartOfLine('\|\|') ?
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
inoreabbrev <expr> __
\ <SID>isAtStartOfLine('__') ?
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
" ===================== End of Plugin Settings =====================
- 第四步
运行nvim-qt.exe,输入PlugInstall命令安装插件;安装完成后,手动下载 markdown-preview-win.exe (地址:https://github.com/iamcco/markdown-preview.nvim/releases)到目录~\AppData\Local\nvim-data\site\plugged\markdown-preview.nvim\app\bin