portable, powerful yet lightweight vimrc config for vim/neovim
main feature:
- cross platform, and keep similar user experience for these platforms
- low dependency, no anoying lag or errors for old versions and envs
- can be installed completely portable, best for servers
- powerful for general usage
should work, for almost all of real vim envs:
- vim 7.3 or above
- neovim 0.3 or above
- Windows's gVim
- cygwin's vim
- Mac OS's vim and macvim (console or GUI)
- Ubuntu's vim
- Android's DroidVim
may work, on vim simulation envs: (search and see g:zf_fakevim)
- IntelliJ IDEA's IdeaVim (good to use)
- Qt Creator's FakeVim (able to use)
- VisualStudio's VsVim (able to use)
- XCode's XVim (not recommended)
if you like my work, check here for a list of my vim plugins, or buy me a coffee
~/
.vim/
bundle/ // all plugins placed here
ZFVimModule/ // (optional) you may supply all your custom setting here
// *.vim under this dir would be sourced automatically
// files are ensured to be sourced by name order
zf_vimrc.ext/ // (optional, but installed by default)
// contains useful but heavy dependencies, such as LSPs
vimrc.local.vim // (optional) your custom local setting for current machine
YourGitRepo/ // (optional) your custom module
ZFInit/ // sourced during init
ZFPlugPrev/ // sourced just after `vim-plug`'s `plug#begin()`
ZFPlugPost/ // sourced just before `vim-plug`'s `plug#end()`
ZFFinish/ // sourced after all other source
.vim_cache/ // cache files of this repo
.vimrc // vim's default config file
zf_vimrc.vim // this repo's main config file
the location of files installed by this config, can be configured by:
let g:zf_vim_data_path=$HOME . '/.vim'
let g:zf_vim_cache_path=$HOME . '/.vim_cache'
you may even use this repo completely portable (see Portable Mode below),
with this directory structure:
any_path/
zf_vimrc.vim/ // this repo's root
.zfvim/ // all config files generated here
.vim/
bundle/ // all plugins
ZFVimModule/ // optional modules
.vim_cache/ // cache files
zfvim/ // entry script to start with
zfvim
zfnvim
zf_vimrc.vim // this repo's main config file
if you have curl, git, vim installed, here's a very simple command to install everything:
curl zsaber.com/vim | sh
# or, copy the `zf_vim_install.sh` to anywhere and then simply run it
sh zf_vim_install.sh
once installed, you may press z? to view a quick tutorial for this config
if you just want to quickly test this repo, or prefer run from portable disks:
-
use the Quick Install script
curl zsaber.com/vim | shthe script would prompt for some install options, when you get this:
[ZFVim] install locally? [n/y/path_to_install]:input
yor any path (such as./zf_vimrc.local) would make it install to the specified local dir, and you may use the util script to launch:./zf_vimrc.local/zfvim/zfvim -
install manually
# clone this repo git clone https://github.com/ZSaberLv0/zf_vimrc.vim # ensure it's executable chmod +x ./zf_vimrc.vim/zfvim/zfvim # simply run from util script ./zf_vimrc.vim/zfvim/zfvim
for lazy ones, here's a packaged portable version of gVim for Windows: Download
it's not ensured keep update with this repo, but you may use <leader>vimru to update
you may use export ZFVim_xxx=yyy before curl zsaber.com/vim | sh to make it active,
or, by default, the quick install script would prompt for these options
-
ZFVim_githost: git hostdefault: empty for
https://github.comuseful mirrors:
https://hub.fastgit.orghttps://github.com.cnpmjs.org
-
ZFVim_local:[n/y/path_to_install]whether install locallydefault: n
- when
ZFVim_local=y, try to install to./zf_vimrc.local - otherwise, when not empty, try to install to
./$ZFVim_local
when installed locally, all files are placed under the specified dir (see
Directory Structureabove), it's convenient to test this repo without messed up your own, or use as portable config on server or USB devicesto use the local version, use
path/to/zf_vimrc.local/zfvim/zfvim, orexport PATH=$PATH:path_to_zfvimfor convenientby default, the portable
zfvimwould work as "full" version, which would disable huge plugins such as LSPs, and here's all the versions:zfvim: same aszfvim --fullzfvim --full: full versionzfvim --mini: mini version with LSPs disabledzfvim --tiny: tiny version with all plugins disabled
- when
-
ZFVim_force:[n/y]remove all contents and perform clean installdefault: n
these items would be removed before install
~/.vimrc ~/_vimrc ~/.vim ~/.config/nvim/init.vim -
ZFVim_modules:[n/y]whether try to install external command line toolsdefault: n
-
ZFVim_neovim:[y/n]also install to neovim, which would addsource ~/zf_vimrc.vimto~/.config/nvim/init.vimdefault: y if
nvimexist in your shell
-
ensure
gitare available in yourPATH -
download or clone the
zf_vimrc.vimfile to anywhere -
have these in your
.vimrc(under linux) or_vimrc(under Windows):source path/zf_vimrc.vim -
open your vim, plugins should be installed automatically
for a list of plugins and configs, please refer to the zf_vimrc.vim itself, which is self described
to uninstall, remove these lines in your .vimrc and .config/nvim/init.vim
source path/zf_vimrc.vim
and remove these dirs/files if exists
$HOME/.vim
$HOME/.vim_cache
$HOME/zf_vimrc.vim
to uninstall, simply remove the generated dir,
which is ./zf_vimrc.local by default
-
not necessary, but strongly recommended for Windows users
-
GNU grep (greater than 2.5.3)
for vim-easygrep if you want to use Perl style regexp
note the FreeBSD version won't work due to the lack of
-Poption ofgrep -
external command line tools
you may use
:ZFModuleInstallto install other additional external command line tools, this may take a long time
this config is fully modularized, it's recommended to supply your own setting in ~/.vim/ZFVimModule:
~/
.vim/
ZFVimModule/
vimrc.local.vim // recommended to supply platform-dependent settings for local machine
YourGitRepo1/ // you may supply extra config as git repo,
// with specified directory structure
ZFInit/ // sourced during init,
// config for `zf_vimrc.vim` itself can be placed here,
// for example `let g:ZF_Plugin_agit = 0` to disable builtin plugin
a.vim // all *.vim files would be sourced,
b.vim // and are ensured ordered by file name
ZFPlugPrev/ // sourced just after `plug#begin()`,
// you may add your own plugin here,
// for example: `ZFPlug 'UserName/PlugName'`
ZFPlugPost/ // sourced just before `plug#end()`
ZFFinish/ // sourced after all other source,
// can be used to override some config of `zf_vimrc.vim`
YourGitRepo2/ // you may supply any number of extra config
ZFInit/
ZFPlugPrev/
ZFPlugPost/
ZFFinish/
see zf_vimrc.ext for example
usually, complete engines have heavy dependencies and hard to config,
so we separate these configs to zf_vimrc.ext
to make this repo simple and clean,
the zf_vimrc.ext would also be installed by default,
but you should go zf_vimrc.ext/README.md
for how to properly setup LSPs
when used under ssh of some new version of MacOS, you may get some weird error message,
that's because the default shell was changed to zsh
and it does not properly set $LANG,
to solve this, add this line to your ~/.zprofile or ~/.zshrc
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
when used under different version of cygwin, you should concern these settings if weird problem occurred:
set shell=cmd.exe
set shellcmdflag=/c
or
set shell=bash
set shellcmdflag=-c
set it directly to .vimrc, choose the right one for you
-
the vim config is placed under
/data/data/com.droidvim/files/home/.vimrc -
you should manually copy all settings from other platform to DroidVim's folder, the result folder tree should looks like:
/data/data/com.droidvim/files/home/ .vim/ bundle/ ... .vimrc zf_vimrc.vim
-
VimTouch Full Runtimeis also required -
the vim config is placed under
/data/data/net.momodalo.app.vimtouch/files/.vimrc -
you should manually copy all settings from other platform to VimTouch's folder, the result folder tree should looks like:
/data/data/net.momodalo.app.vimtouch/files/ .vim/ bundle/ ... .vimrc zf_vimrc.vim
Note: VimTouch's vimrc may or may not be sourced under Android 5 or above, reason unknown, this is VimTouch's problem, not this repo's problem
let g:zf_fakevim = 1
source path/to/zf_vimrc.vim
- not fully tested
- some vim simulation plugins doesn't support
sourcecommand, so you may need to paste directly to proper vimrc files (e.g..xvimrc) - some vim simulation plugins doesn't support
if-statementand plugins, so you may need to manually delete all lines under theif g:zf_no_plugin!=1section
recommended to:
-
(for MacOS only)
defaults write -g ApplePressAndHoldEnabled 0 -
install
IdeaVim-EasyMotionandAceJumpplugin (within your IDE's plugin manager) -
add these configs to your
~/.ideavimrclet mapleader="'" let g:zf_fakevim=1 source ~/zf_vimrc.vim nnoremap <esc> <esc>:action HideActiveWindow<cr> nmap <c-o> :action SearchEverywhere<cr> nmap zu :action GoToErrorGroup<cr> nmap zi :action ShowIntentionActions<cr> nmap zo :action OverrideMethods<cr> nmap X :action CloseAllEditorsButActive<cr> nmap H :action PreviousTab<cr> nmap L :action NextTab<cr> nmap CC :action CommentByLineComment<cr><up> xmap CC :action CommentByLineComment<cr><esc> nmap t :action EditorSelectWord<cr> xmap t :action EditorSelectWord<cr> nmap T :action EditorUnSelectWord<cr> xmap T :action EditorUnSelectWord<cr> nmap DB :action ToggleLineBreakpoint<cr> nmap DV :action ViewBreakpoints<cr> nmap DC :action ViewBreakpoints<cr> nmap DF :action ShowHoverInfo<cr> nmap <f4> :action Stop<cr> nmap <f5> :action Debug<cr> nmap DS :action Resume<cr> nmap Ds :action Pause<cr> nmap DU :action StepOut<cr> nmap <f9> :action StepOut<cr> nmap DO :action StepOver<cr> nmap <f10> :action StepOver<cr> nmap DI :action StepInto<cr> nmap <f11> :action StepInto<cr> set NERDTree nmap <leader>ve :NERDTreeToggle<cr> nmap <leader>ze :NERDTreeFind<cr> set easymotion nmap s <plug>(easymotion-s) xmap s <plug>(easymotion-s) nmap S <plug>(easymotion-bd-jk) xmap S <plug>(easymotion-bd-jk) let g:EasyMotion_startofline = 1 set surround let g:surround_no_mappings = 1 nmap rd <plug>DSurround nmap RD <plug>DSurround nmap rc <plug>CSurround nmap RC <plug>CSurround xmap r <plug>VSurround xmap R <plug>VSurround
recommended to:
-
add these configs to your
~/_vimrclet g:zf_fakevim=1 source ~/zf_vimrc.vim nnoremap <esc> <esc>:vsc Window.HideShowAllToolWindows<cr> nmap <c-o> :vsc Edit.NavigateTo<cr> nmap zj :vsc Edit.GoToDefinition<cr> nmap zk :vsc View.NavigateBackward<cr> nmap zu :vsc View.ErrorList<cr> nmap zi :vsc View.QuickActions<cr> nmap X :vsc File.CloseOtherTabs<cr> nmap H :vsc Window.PreviousTab<cr> nmap L :vsc Window.NextTab<cr> nmap CC :vsc Edit.ToggleLineComment<cr> xmap CC :vsc Edit.ToggleLineComment<cr> nmap t :vsc Edit.ExpandSelection<cr> xmap t :vsc Edit.ExpandSelection<cr> nmap T :vsc Edit.SelectionCancel<cr> xmap T :vsc Edit.SelectionCancel<cr> nmap DB :vsc Debug.ToggleBreakpoint<cr> nmap DV :vsc Debug.Breakpoints<cr> nmap DC :vsc Debug.DeleteAllBreakpoints<cr> nmap DF :vsc Debug.QuickWatch<cr> nmap <f4> :vsc Debug.StopDebugging<cr> nmap <f5> :vsc Debug.Start<cr> nmap DS :vsc Debug.RunToCursor<cr> nmap <f8> :vsc Debug.RunToCursor<cr> nmap Ds :vsc Debug.BreakAll<cr> nmap DU :vsc Debug.StepOut<cr> nmap <f9> :vsc Debug.StepOut<cr> nmap DO :vsc Debug.StepOver<cr> nmap <f10> :vsc Debug.StepOver<cr> nmap DI :vsc Debug.StepInto<cr> nmap <f11> :vsc Debug.StepOver<cr>