Bash Script to Compile and Install Vim from Source

#!/usr/bin/env sh

# Install system dependencies
sudo apt install libncurses5-dev python-dev python3-dev git checkinstall

# Remove Vim if you already have 
sudo apt remove vim vim-runtime gvim  

# Configure and make
cd ~/repos
git clone https://github.com/vim/vim.git
cd vim

sudo make distclean

sudo ./configure \
    --with-features=huge \
    --without-x \
    --disable-xsmp \
    --disable-rightleft --disable-arabic \
    --enable-python3interp \
    --with-python3-command=python3 \
    --with-python3-config-dir=$(python3-config --configdir|rev|cut -d/ -f1 --complement|rev) \
    --disable-gui \
    --enable-cscope \
    --disable-netbeans \
    --enable-fail-if-missing \
    --prefix=/usr/local/
    
sudo make

# Install
sudo checkinstall

# Set Vim as a default editor
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim   

# Check if it worked
vim --version

2024/11/15 Update - Still Works

Looks like the --disable-gui flag is not working or has changed though since it installed with GTK2 GUI enabled.

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Nov 15 2024 21:29:13)
Included patches: 1-867
Compiled by xan@xan-ipod
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
-arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
+balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
+browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   +toolbar
+cindent           +job               +popupwin          +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          -rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con_gui    +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            +X11
+digraphs          +mouse             -sound             +xattr
+dnd               +mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       +xim
+emacs_tags        -mouse_gpm         +statusline        +xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            +xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static

Tags

 Vim  linux  bash  scripts