VIM: Difference between revisions

From Han Wiki
Jump to navigation Jump to search
dump from oldwiki
No edit summary
 
(46 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Adding comments to a block =
I have a separate page for [[Neovim]].
 
= Keyboard shortcuts =
 
* <code>Ctrl + w t</code> <code>Ctrl + w K</code> - change split windows from vertical to horizontal split
* <code>Ctrl + w t</code> <code>Ctrl + w H</code> - change split windows from horizontal to vertical split
* <code>" + f + p</code> - paste the saved macro bound to f
* <code>" + 2 + p</code> - paste from a past yank at register #2
 
= With highlighted text =
 
* <code>~</code> - reverse capitalization
 
= New developments with v8 =
 
With the dawn of Neovim in 2014, there were two major new developments: non-blocking, asynchronous execution, and terminal
 
 
= vimscript =
 
* [http://learnvimscriptthehardway.stevelosh.com/ Learn the Vimscript Hard Way]
 
 
= Instructions =
 
== add line numbers ==
 
Visual highlight and then start with number 42
 
<syntaxhighlight lang="vim">
:'<,'>s/^/\=(line('.')-line("'<")+42).' --> '/
</syntaxhighlight>
 
== beautify json ==
 
<syntaxhighlight lang="vim">
:%!python -m json.tool
</syntaxhighlight>
 
 
== Save a useful macro and retrieve for later use ==
 
In ~/.vimrc file, add as follows.  Macro content can be retrieved by pressing <code>"xp</code> where x is the bound key.
 
<syntaxhighlight lang="vim">
let @q = 'macro contents'
</syntaxhighlight>
 
 
== Adding comments to a block ==
 
=== Method 1 ===


Grab lines with visual block and then <code>:norm i#</code> to comment, and then <code>:norm x</code> or <code>:norm ^x</code> with indentation.
Grab lines with visual block and then <code>:norm i#</code> to comment, and then <code>:norm x</code> or <code>:norm ^x</code> with indentation.


= Emmet =


Also known as Zen Coding previously.
=== Method 2 ===
 
'''Commenting a block'''
 
# Ctrl-v and select multiple lines to comment
# Shift-I
# Add comment characters to add and then press Esc
 
'''Uncommenting a block'''
 
# Ctrl-v and select the block to uncomment
# press x
 
 
== Auto-format HTML ==
 
1) Join all the lines
 
<syntaxhighlight lang="vim">
(highlight lines) gJ
</syntaxhighlight>
 
 
2) Break tags to new lines
 
<syntaxhighlight lang="vim">
(highlight lines) :s/>\s*</>\r</g
</syntaxhighlight>
 
 
3) Set filetype
 
<syntaxhighlight lang="vim">
:set ft=html
</syntaxhighlight>
 
 
4) Indent
 
<syntaxhighlight lang="vim">
(highlight lines) =
</syntaxhighlight>
 
== Remove all HTML tags ==
 
<syntaxhighlight lang="vim">
:%s/<\_.\{-1,\}>//g
</syntaxhighlight>
 


* [http://docs.emmet.io/cheat-sheet/ Emmet cheatsheet]
== netrw ==


= Miscellaneous =
=== commonly used actions ===


== Fixing an issue with Python version when using VIM with some packages ==
* <code>d</code> create a new folder
* ''Last tested on Ubuntu 16.04 LTS (xenial) | easy | less than five minutes''
* <code>%</code> create a new file


When running <code>vim</code> with Powerline package on Ubuntu 16.04, I get this error message every time I execute it from the CLI.
= .vimrc =


<source lang="bash">
With the introduction of internal package management system, there is no longer a logical need to install a third-party package management tool. Here's a refresh of my .vimrc as of mid-2018 with VIM v8.
$ vim
UltiSnips requires py >= 2.7 or py3
You need vim compiled with Python 2.6, 2.7 or 3.2 and later support
for Powerline to work. Please consult the documentation for more
details.
Press ENTER or type command to continue
</source>


I'm not sure what this does, but this seems to solve the problem. Thanks to Sergey Khaylov for the answer at [http://stackoverflow.com/questions/20160902/how-to-solve-requires-python-2-x-support-in-linux-vim-and-it-have-python-2-6-6 Stackoverflow].
<syntaxhighlight lang="vim">
if &compatible
  set nocompatible
endif


<source lang="bash">
if has('packages')
$ apt-get install vim-nox
  packloadall
</source>
else
  " Use vim-plug
  filetype off
  source $HOME/.vim/plugged/vim-plug/plug.vim
  call plug#begin('~/.vim/plugged')
  call plug#end()
endif


syntax on
</syntaxhighlight>


= Initial setup =
= Initial setup (deprecated) =


Install [https://github.com/Shougo/neobundle.vim Shougo/neobundle.vim] from Github. It's a new package management tool for Vim that utilizes the Github repository.
Install [https://github.com/Shougo/neobundle.vim Shougo/neobundle.vim] from Github. It's a new package management tool for Vim that utilizes the Github repository.


Here is my entire ~/.vimrc file.
Here is my entire ~/.vimrc file.
<source lang="vim" enclose="div">
<syntaxhighlight lang="vim" enclose="div">
set nocompatible
set nocompatible
set noexpandtab
set noexpandtab
Line 103: Line 205:


autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP
autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP
</source>
</syntaxhighlight>


<code>set nocompatible</code> - forget about making Vim behave like Vi.
<code>set nocompatible</code> - forget about making Vim behave like Vi.
Line 127: Line 229:
<code>set ruler</code> - information such as line number and current position in the file are displayed on the status line
<code>set ruler</code> - information such as line number and current position in the file are displayed on the status line


<code>set foldmethod=indent</code> - another foldmethod I use regularly is marker ({{{ & }}}) when documenting code, but indent is a good start for reading through long lines of code
<code>set foldmethod=indent</code> - another foldmethod I use regularly is marker <nowiki>({{{ & }}})</nowiki> when documenting code, but indent is a good start for reading through long lines of code


<code>set foldnestmax=15</code> - the nest level for the code folding
<code>set foldnestmax=15</code> - the nest level for the code folding
Line 159: Line 261:
<code>NeoBundleFetch 'Shougo/neobundle.vim'</code> - as required by NeoBundle
<code>NeoBundleFetch 'Shougo/neobundle.vim'</code> - as required by NeoBundle


</code>filetype plugin indent on</code> - allow plugins to change the indent behavior (??)
filetype plugin indent on - allow plugins to change the indent behavior (??)


All those NeoBundle 'owner/package' lines are for installation of packages
All those NeoBundle 'owner/package' lines are for installation of packages
Line 208: Line 310:
:<nowiki>:</nowiki>syntax on
:<nowiki>:</nowiki>syntax on


= Possibly outdated by 2014 =
;Remove HTML tags
:<nowiki>:%s/<\_.\{-1,\}>//g</nowiki>
 
;Replace all tabs with 4 spaces
:%retab
 
;Set tab to 4 spaces
:set expandtab ts=4 sw=4 ai
 
;Remove trailing whitespaces
:%s/\s\+$//e
 
= gvim on Windows 10 =
 
== Setting GUI font in .vimrc ==
 
<syntaxhighlight lang="vim">
if has("gui_running")
  if has("gui_gtk2")
    set guifont=Inconsolata\ 12
  elseif has("gui_macvim")
    set guifont=Menlo\ Regular:h14
  elseif has("gui_win32")
    set guifont=Consolas:h11:cANSI
  endif
endif
</syntaxhighlight>
 
== Installing vim-plug ==
 
{{testedon|2019-12-06|Windows 10 v1903 (build#18362.449),VIM 8.1.1657}}


== CTAG ==
<syntaxhighlight lang="doscon">
PS C:\> $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile(
  $uri,
  $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
    "~\vimfiles\autoload\plug.vim"
  )
)
</syntaxhighlight>
 
== Ultisnips requires py >= 2.7 or py3 ==
 
{{testedon|2019-12-06|Windows 10 v1903 (build#18362.449),VIM 8.1.1657,Python 3.8}}
 
This may not be the best method, so it's more of a workaround. Install Python3 (e.g. via Chocolatey) and make a copy of pythonXX.dll under the python folder (e.g. \Python38) to the version that vim is looking for. For example, if Python 3.8 was installed, but vim is compiled with Python 3.7, then you would make a copy as follows:
 
<syntaxhighlight lang="doscon">
C:\Python38> copy python38.dll python37.dll
</syntaxhighlight>
 
== Plug-ins ==
 
=== Hangeul ===
 
* [http://mearie.org/projects/vim-hangeul/ hangeul.vim | 메아리 프로젝트 (mearie.org)]
 
=== Emmet ===
 
Also known as Zen Coding previously.
 
* [http://docs.emmet.io/cheat-sheet/ Emmet cheatsheet]
 
=== Conquer of Completion ===
 
* [https://github.com/neoclide/coc.nvim neoclide/coc.nvim]
<syntaxhighlight lang="vim">
:CocInstall coc-tsserver coc-json coc-html coc-git coc-css coc-phpls coc-blade coc-docker coc-emmet coc-powershell coc-sql coc-tailwindcss coc-xml coc-yaml
 
:CocInstall @yaegassy/coc-laravel @yaegassy/coc-nginx
</syntaxhighlight>
 
=== NERDTree ===
 
* [https://github.com/preservim/nerdtree preservim/nerdtree]
 
==== Shortcuts ====
 
<code>Shift + i</code> Toggle showing of the hidden files
 
=== gitgutter ===
 
* Activation (default on): <code>:GitGutterDisable</code>, <code>:GitGutterEnable</code>, <code>:GitGutterToggle</code>
* Signs toggle (default on): <code>:GitGutterSignsDisable</code>, <code>:GitGutterSignsEnable</code>, <code>:GitGutterSignsToggle</code>
* Highlights toggle (default off): <code>:GitGutterLineHighlightsDisable</code>, <code>:GitGutterLineHighlightsEnable</code>, <code>:GitGutterLineHighlightsToggle</code>
* Hunks
** Jump between hunks: <code>[c</code>, <code>]c</code>
** Stage hunk: <code><nowiki><Leader></nowiki>hs</code>
** Undo changes: <code><nowiki><Leader></nowiki>hu</code>
** Preview hunk's changes: <code><nowiki><Leader></nowiki>hp</code>
 
=== CTAG ===
 
''Possibly outdated by 2014''


;Rebuild a ctag file from a current project (assuming extensions are abc & def)
;Rebuild a ctag file from a current project (assuming extensions are abc & def)
Line 219: Line 413:
;http://runpaint.org/
;http://runpaint.org/
:vim and other tech books
:vim and other tech books
= Miscellaneous =
== Check VIM version ==
{{testedon|2013-08-10|VIM 7.4}}
<syntaxhighlight lang="vim">
:ve
</syntaxhighlight>
== Reload .vimrc without quitting ==
{{testedon|2013-08-10|VIM 7.4}}
<syntaxhighlight lang="vim">
:so ~/.vimrc
</syntaxhighlight>
== Fixing an issue with Python version when using VIM with some packages ==
{{testedon|xenial|Ubuntu 16.04 LTS}}
When running <code>vim</code> with Powerline package on Ubuntu 16.04, I get this error message every time I execute it from the CLI.
<syntaxhighlight lang="console" highlight="1">
$ vim
UltiSnips requires py >= 2.7 or py3
You need vim compiled with Python 2.6, 2.7 or 3.2 and later support
for Powerline to work. Please consult the documentation for more
details.
Press ENTER or type command to continue
</syntaxhighlight>
I'm not sure what this does, but this seems to solve the problem. Thanks to Sergey Khaylov for the answer at [http://stackoverflow.com/questions/20160902/how-to-solve-requires-python-2-x-support-in-linux-vim-and-it-have-python-2-6-6 Stackoverflow].
<syntaxhighlight lang="bash">
$ apt-get install vim-nox
</syntaxhighlight>
= Compiling with python supports =
{{testedon|2023-10-03|RHEL 8.8}}
<syntaxhighlight lang="bash">
$ ./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=/usr/lib64/python2.7/config --enable-python3interp --with-python3-config-dir=/usr/lib64/python3.6/config-3.6m-x86_64-linux-gnu --prefix=/usr --enable-fail-if-missing
</syntaxhighlight>
= Links =
[https://dev.to/jovica/the-vim-trick-which-will-save-your-time-and-nerves-45pg The VIM trick which will save your time and nerves]

Latest revision as of 21:23, 15 March 2024

I have a separate page for Neovim.

Keyboard shortcuts

  • Ctrl + w t Ctrl + w K - change split windows from vertical to horizontal split
  • Ctrl + w t Ctrl + w H - change split windows from horizontal to vertical split
  • " + f + p - paste the saved macro bound to f
  • " + 2 + p - paste from a past yank at register #2

With highlighted text

  • ~ - reverse capitalization

New developments with v8

With the dawn of Neovim in 2014, there were two major new developments: non-blocking, asynchronous execution, and terminal


vimscript


Instructions

add line numbers

Visual highlight and then start with number 42

:'<,'>s/^/\=(line('.')-line("'<")+42).' --> '/

beautify json

:%!python -m json.tool


Save a useful macro and retrieve for later use

In ~/.vimrc file, add as follows. Macro content can be retrieved by pressing "xp where x is the bound key.

let @q = 'macro contents'


Adding comments to a block

Method 1

Grab lines with visual block and then :norm i# to comment, and then :norm x or :norm ^x with indentation.


Method 2

Commenting a block

  1. Ctrl-v and select multiple lines to comment
  2. Shift-I
  3. Add comment characters to add and then press Esc

Uncommenting a block

  1. Ctrl-v and select the block to uncomment
  2. press x


Auto-format HTML

1) Join all the lines

(highlight lines) gJ


2) Break tags to new lines

(highlight lines) :s/>\s*</>\r</g


3) Set filetype

:set ft=html


4) Indent

(highlight lines) =

Remove all HTML tags

:%s/<\_.\{-1,\}>//g


netrw

commonly used actions

  • d create a new folder
  • % create a new file

.vimrc

With the introduction of internal package management system, there is no longer a logical need to install a third-party package management tool. Here's a refresh of my .vimrc as of mid-2018 with VIM v8.

if &compatible
  set nocompatible
endif

if has('packages')
  packloadall
else
  " Use vim-plug
  filetype off
  source $HOME/.vim/plugged/vim-plug/plug.vim
  call plug#begin('~/.vim/plugged')
  call plug#end()
endif

syntax on

Initial setup (deprecated)

Install Shougo/neobundle.vim from Github. It's a new package management tool for Vim that utilizes the Github repository.

Here is my entire ~/.vimrc file.

set nocompatible
set noexpandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smartindent
set autoindent
set encoding=utf-8
set number
set autowrite
set ruler
set foldmethod=indent
set foldnestmax=15
set nofoldenable
set foldlevel=1
set timeoutlen=500
set hidden
set t_Co=256
set statusline=%F\ \%{fugitive#statusline()}\ \%=\ \%y\ -\ %l/%L
set laststatus=2
set runtimepath+=~/.vim/bundle/neobundle.vim/
let g:phpcomplete_index_composer_command="composer"

let g:Powerline_symbols = "fancy"

let g:gitgutter_sign_added = '++'
let g:gitgutter_sign_modified = 'MM'
let g:gitgutter_sign_removed = '--'
let g:gitgutter_sign_modified_removed = 'M-'

call neobundle#rc(expand('~/.vim/bundle/'))

NeoBundleFetch 'Shougo/neobundle.vim'

filetype plugin indent on

NeoBundle 'Shougo/vimproc', {
      \ 'build' : {
      \     'windows' : 'make -f make_mingw32.mak',
      \     'cygwin' : 'make -f make_cygwin.mak',
      \     'mac' : 'make -f make_mac.mak',
      \     'unix' : 'make -f make_unix.mak',
      \    },
     \ }
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/vimshell.vim'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'Lokaltog/powerline',{'rtp': 'powerline/bindings/vim/'}
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'vim-scripts/sudo.vim'
NeoBundle 'm2mdas/phpcomplete-extended'
NeoBundle 'm2mdas/phpcomplete-extended-laravel'
NeoBundle 'chriskempson/vim-tomorrow-theme'

NeoBundleCheck

filetype plugin indent on

colorscheme torte
highlight LineNr ctermfg=darkgrey
highlight SignColumn ctermbg=black
highlight Folded ctermfg=11 ctermbg=23

autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP

set nocompatible - forget about making Vim behave like Vi.

set noexpandtab - do not expand tabs into spaces; use the tab character

set tabstop=4 - uses 4 character spaces for a tab

set shiftwidth=4 - move 4 spaces for reindent operation (<< or >> shortcut keys)

set softtabstop=4 - number of spaces a tab uses in INSERT mode

set smartindent - use smart indent mode -- i.e. entering after a opening bracket would automatically indent and in other similar situations

set autoindent - use the same indentation as the last line

set encoding=utf-8 - set encoding

set number - turn on line numbers (set nonumber to turn it off)

set autowrite - automatically save when changing between buffers

set ruler - information such as line number and current position in the file are displayed on the status line

set foldmethod=indent - another foldmethod I use regularly is marker ({{{ & }}}) when documenting code, but indent is a good start for reading through long lines of code

set foldnestmax=15 - the nest level for the code folding

set nofoldenable - you don't want Vim to fold your code by default on initial load of a file

set foldlevel=1 - when executing close command for code folding everything will be folded down to level 1, or the top level

set timeoutlen=500 - keycode delay to be used; default is 1000, but this reduces the polling time when you press on a Esc to change modes

set hidden - allows loading of a buffer in a window that has a modified buffer

set t_Co=256 - allow Vim to understand that the terminal is using 256 colors

set statusline=%F\ \%{fugitive#statusline()}\ \%=\ \%y\ -\ %l/%L - this is the default for the fugitive installation

set laststatus=2 - turn the status line on

set runtimepath+=~/.vim/bundle/neobundle.vim/ - required for neobundle installation

let g:phpcomplete_index_composer_command="composer" - by default, it is "php composer.phar", so this is according to how you've customized your development environment

let g:Powerline_symbols="fancy" - I haven't confirmed this yet, but this probably allows Lokaltog/powerline plugin to use Private Use Area of the Unicode of fonts specifically patched for Powerline characters

let g:gitgutter_sign_added = '++' - I like my GitGutter to occupy two characters for better visibility

...

call neobundle#rc(expand('~/.vim/bundle/')) - I think this sets this directory as NeoBundle's target bundle directory; required by NeoBundle

NeoBundleFetch 'Shougo/neobundle.vim' - as required by NeoBundle

filetype plugin indent on - allow plugins to change the indent behavior (??)

All those NeoBundle 'owner/package' lines are for installation of packages

NeoBundle 'Shougo/vimproc'... - vimproc allows real-time update of certain components that uses this package

NeoBundle 'Shougo/unite.vim' - similar to ctrlp, allows extensive searching features and UI

NeoBundle 'Shougo/vimshell.vim' - allows bash shell like interface within vim

NeoBundle 'airblade/vim-gitgutter' - Git diff marks are displayed somewhat realtime

NeoBundle 'Lokaltog/powerline',{'rtp': 'powerline/bindings/vim/'} - one of the most popular status line plugins

NeoBundle 'tpope/vim-fugitive' - run Git commands within Vim

NeoBundle 'kien/ctrlp.vim' - extensive searching tool

NeoBundle 'vim-scripts/sudo.vim' - installed to get rid of the annoying msg while running Vim as a sudo

NeoBundle 'm2mdas/phpcomplete-extended' - command completion similar to ones found in many GUI IDEs

NeoBundle 'm2mdas/phpcomplete-extended-laravel' - this is add-on allows completion for Laravel 4

NeoBundle 'chriskempson/vim-tomorrow-theme' - I sometimes use this theme

NeoBundleCheck - NeoBundle requires this

colorscheme torte - Use this color scheme -- a default one I like

highlight LineNr ctermfg=darkgrey - color of the line numbers

highlight SignColumn ctermbg=black - color of the gutter used by GitGutter

highlight Folded ctermfg=11 ctermbg=23 - the default folded code color is an eyesore, so replace it

autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP - this completes the phpcomplete_extended plugin installation

Useful commands

Turn number lines
:set number
Wordwrap off
:set nowrap
Syntax on
:syntax on
Remove HTML tags
:%s/<\_.\{-1,\}>//g
Replace all tabs with 4 spaces
%retab
Set tab to 4 spaces
set expandtab ts=4 sw=4 ai
Remove trailing whitespaces
%s/\s\+$//e

gvim on Windows 10

Setting GUI font in .vimrc

if has("gui_running")
  if has("gui_gtk2")
    set guifont=Inconsolata\ 12
  elseif has("gui_macvim")
    set guifont=Menlo\ Regular:h14
  elseif has("gui_win32")
    set guifont=Consolas:h11:cANSI
  endif
endif

Installing vim-plug

  • Last tested on Windows 10 v1903 (build#18362.449),VIM 8.1.1657 (2019-12-06)
PS C:\> $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile(
  $uri,
  $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
    "~\vimfiles\autoload\plug.vim"
  )
)

Ultisnips requires py >= 2.7 or py3

  • Last tested on Windows 10 v1903 (build#18362.449),VIM 8.1.1657,Python 3.8 (2019-12-06)

This may not be the best method, so it's more of a workaround. Install Python3 (e.g. via Chocolatey) and make a copy of pythonXX.dll under the python folder (e.g. \Python38) to the version that vim is looking for. For example, if Python 3.8 was installed, but vim is compiled with Python 3.7, then you would make a copy as follows:

C:\Python38> copy python38.dll python37.dll

Plug-ins

Hangeul

Emmet

Also known as Zen Coding previously.

Conquer of Completion

:CocInstall coc-tsserver coc-json coc-html coc-git coc-css coc-phpls coc-blade coc-docker coc-emmet coc-powershell coc-sql coc-tailwindcss coc-xml coc-yaml

:CocInstall @yaegassy/coc-laravel @yaegassy/coc-nginx

NERDTree

Shortcuts

Shift + i Toggle showing of the hidden files

gitgutter

  • Activation (default on): :GitGutterDisable, :GitGutterEnable, :GitGutterToggle
  • Signs toggle (default on): :GitGutterSignsDisable, :GitGutterSignsEnable, :GitGutterSignsToggle
  • Highlights toggle (default off): :GitGutterLineHighlightsDisable, :GitGutterLineHighlightsEnable, :GitGutterLineHighlightsToggle
  • Hunks
    • Jump between hunks: [c, ]c
    • Stage hunk: <Leader>hs
    • Undo changes: <Leader>hu
    • Preview hunk's changes: <Leader>hp

CTAG

Possibly outdated by 2014

Rebuild a ctag file from a current project (assuming extensions are abc & def)
find . -type f -name \*.abc -o -name \*.def | xargs ctags --language-force=php
(to add more extensions) find . -type f -name \*.ghi | xargs ctags -a --language-force=;http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/
ctags and taglist
http://runpaint.org/
vim and other tech books

Miscellaneous

Check VIM version

  • Last tested on VIM 7.4 (2013-08-10)
:ve

Reload .vimrc without quitting

  • Last tested on VIM 7.4 (2013-08-10)
:so ~/.vimrc

Fixing an issue with Python version when using VIM with some packages

  • Last tested on Ubuntu 16.04 LTS (xenial)

When running vim with Powerline package on Ubuntu 16.04, I get this error message every time I execute it from the CLI.

$ vim
UltiSnips requires py >= 2.7 or py3
You need vim compiled with Python 2.6, 2.7 or 3.2 and later support
for Powerline to work. Please consult the documentation for more
details.
Press ENTER or type command to continue

I'm not sure what this does, but this seems to solve the problem. Thanks to Sergey Khaylov for the answer at Stackoverflow.

$ apt-get install vim-nox

Compiling with python supports

  • Last tested on RHEL 8.8 (2023-10-03)
$ ./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=/usr/lib64/python2.7/config --enable-python3interp --with-python3-config-dir=/usr/lib64/python3.6/config-3.6m-x86_64-linux-gnu --prefix=/usr --enable-fail-if-missing

Links

The VIM trick which will save your time and nerves