Building Vim from source code
introduction
The thing is like this, because I'm a heavy user of Vim..
However, the version that can be installed or comes with on most systems is an older version, possibly 7.0 X or something. Or you need to use some features or functions of Vim, but the program built for you by others is not enabled, which is very embarrassing.
Therefore, we should build our own Vim from the source code
step
Download runtime and source code
The first is to install and compile the necessary libraries. Depending on the situation, you can make up for any errors.
May need these (I don't need to install them myself):
sudo apt install ncurses-dev # or sudo apt install libncurses-dev # or sudo apt install libncurses5-dev \ libgtk2.0-dev \ libatk1.0-dev \ libcairo2-dev \ python-dev \ python3-dev \ git
Then download the source code:
cd ~ && git clone https://github.com/vim/vim.git && cd vim/src
Configure Vim
Because Vim supports many functions, you can turn on or off the functions you need. See here
You can also use this command to view your current Vim version and functions:
$ vim --version | less VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 19 2021 18:24:53) macOS version - x86_64 Included patches: 1-2375 Compiled by Homebrew Huge version without GUI. Features included (+) or not (-): +acl -farsi +mouse_sgr +tag_binary +arabic +file_in_path -mouse_sysmouse -tag_old_static +autocmd +find_in_path +mouse_urxvt -tag_any_white +autochdir +float +mouse_xterm -tcl -autoservername +folding +multi_byte +termguicolors -balloon_eval -footer +multi_lang +terminal +balloon_eval_term +fork() -mzscheme +terminfo -browse +gettext +netbeans_intg +termresponse ++builtin_terms -hangul_input +num64 +textobjects +byte_offset +iconv +packages +textprop +channel +insert_expand +path_extra +timers +cindent +ipv6 +perl +title -clientserver +job +persistent_undo -toolbar +clipboard +jumplist +popupwin +user_commands +cmdline_compl +keymap +postscript +vartabs +cmdline_hist +lambda +printer +vertsplit +cmdline_info +langmap +profile +virtualedit +comments +libcall -python +visual +conceal +linebreak +python3 +visualextra +cryptv +lispindent +quickfix +viminfo +cscope +listcmds +reltime +vreplace +cursorbind +localmap +rightleft +wildignore +cursorshape +lua +ruby +wildmenu +dialog_con +menu +scrollbind +windows +diff +mksession +signs +writebackup +digraphs +modify_fname +smartindent -X11 -dnd +mouse -sound -xfontset -ebcdic -mouseshape +spell -xim +emacs_tags +mouse_dec +startuptime -xpm +eval -mouse_gpm +statusline -xsmp +ex_extra -mouse_jsbterm -sun_workshop -xterm_clipboard +extra_search +mouse_netterm +syntax -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/usr/local/share/vim"
The version number is written in the first line above, and all the features are listed below. Those with + are enabled and those with - are not enabled.
If that's right, now we're in the vim/src directory.
With this command, you can basically turn on the full function:
./configure \ --with-features=huge \ --enable-multibyte \ --enable-rubyinterp \ --enable-perlinterp \ --enable-luainterp \ --enable-pythoninterp \ --with-python-config-dir=/usr/lib/python2.7/config-arm-linux-gnueabihf/ \ --enable-python3interp \ --with-python3-config-dir=/usr/lib/python3.7/config-3.7m-arm-linux-gnueabihf/ \ --enable-gui=gtk2 \ --enable-cscope \ --prefix=/usr
Note: replace the two Python paths with the actual situation on your machine!
Alternatively, if you want to turn off a function that is turned on by default, you can also turn it off in this way:
./configure --enable-multibyte=no --enable-cscope=yes
Directly writing xxx=no will turn off and xxx=yes will turn on. In the above example, we turn off enable multibyte and turn on enable cscope
After the command runs, the program will run a lot of checking. Just wait patiently for it to finish.
install
After running configure, the configuration is set, and then you can install it directly.
make sudo make install
You can also specify the location if you want:
sudo make VIMRUNTIMEDIR=/usr/local/share/vim/vim82
Or specify the maximum number of jobs that can be run to prevent the small machine from being unbearable, because it is not limited to open freely:
make -j 4
After running the make and install commands, vim should be installed. Check again. The version should be the latest.
If there is no change, it may be caused by the cache mechanism of the shell. You can open another shell or update the cache with the following command:
hash vim
It's done~