Making candy out of Vim

You, under the pressure of colleagues or fellow students from more successful groups, have decided on a desperate step that can divide your life into the period "before" and "after" (passed vimtutor) , and now do not know what to do with your newfound abilities? Or maybe you are still sitting in some kind of IDE and don’t blow why you need “these your programming notebooks” and “some kind of Vim there” ? Then sit back and pour yourself lemonade, now I'll put everything on the shelves.













(The article is recommended for sequential reading, but for your convenience, the table of contents is given below)







  1. Introduction
  2. Plugin Manager
  3. Tincture of appearance

  4. Russian language support

  5. Integration with external programs

  6. In brief about (b)

  7. Conclusion




Let's define the terminology



Vim (hereinafter Vim) is, as many already know, a text editor. Of course, changing what you wrote is a very important task, which is a bottleneck in your productivity, but, unfortunately, not everything in this life is so simple, and you (as a user) often need other functionality.







A work environment is a set of software development programs. For example, it may contain a compiler, an interactive console, an editor for positioning GUI elements, a debugger, and more. The editor is just a small piece of this puzzle.







An IDE is an entire work environment concentrated in one place. Of course, there are programs like Emacs (hereinafter referred to as Emax) , where you yourself are free to insert into it everything that you want with the proper skill, but most often it is a ready-made package compiled for you.







Why do I need Wim then if the IDE does everything for me?”







Earlier, its layout was a powerful argument, since for many it is more convenient than modern Emax-like multi-button keyboard shortcuts for navigation and text editing. However, thanks to Neovim and other projects such as VSCodeVim , it is literally everywhere.







However, there is another more powerful argument - performance. The IDE often has a huge amount of functionality that you don’t use, and background processes that heavily load the system. Even if your MacBook does not yell like a fighter from PyCharm or you don’t have scrolling in Visual Studio (which is impossible, you’re my liars) , and Emax’s single-threading doesn’t remind you of the first Crysis or STALKER, the question of energy consumption still arises and, as a result, battery life. Such software in the Linux community is characterized by the meme term "bloat".













- Why Wim?







I already have an article about all the charms of this program. However, it was written by a man under the impression of a new toy with a sophomore intelligence level (guess why) that resulted in such a critically small amount of meaning in it that a black hole formed in its place. Well, at least the funny pictures were a success ...







What can I say about him now, after a year of active use?







  1. He is very fast. Due to the nature of its rendering, Wim has a much lower latency than other editors. After it, other editors seem unresponsive, I'm already silent about the above-mentioned IDEs.
  2. Its use is similar to the passage of the third Dark Souls after the first part. At first it’s difficult and unusual, since the game has become faster and many difficult moments cannot be conceived with the help of the RPG component, but then comes the realization that the game has proved to be true, and almost all the bosses get on the second try.
  3. It practically does not spend resources and runs even on bread, which very well affects the battery.


In principle, there is nothing frankly bad in other editors, so leave this choice to your personal discretion. I am convinced that you can find a similar article for your favorite program. Although, to be honest, editors on electron barely pass by the criterion of energy efficiency.







In this article, we will bring Wim to a digestible state for serious work, and also teach him to be friends with some third-party development programs. Please note that I will only talk about what I happened to encounter personally, and if you have interesting suggestions, then welcome to the comments.









Insert a joke about the plug



The main weapon for configuring our friend are plugins. In fact, these are just separate files with VimScript code that are executed when your settings file (~ / .vimrc or ~ / .config / nvim / init.vim) is loaded with the source command. Using pens to download all this is quite painful, so the great minds of mankind came up with package managers ... for Wim!







The main task of the package manager is to download the specified plugins from the github, provide the user with a convenient interface for managing them, and, in fact, connect them when loading Wim. There are, of course, minimalist managers of the Pathogen type (which deals mainly with only the third) , but we will not complicate our lives so much.







Our ward today will be vim-plug . But, before you go to install it, first you need to add a couple of lines to your config:







filetype plugin indent on "   , ...
"...      
set encoding=utf-8 "  UTF-8
set nocompatible "    Vi
syntax enable "  
      
      





. . Vim Neovim, . :







if empty(glob('~/.vim/autoload/plug.vim')) " vim-plug  
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs " 
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 
  "   
  "    PlugInstall,     
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
      
      





, , . , curl, Neovim ~/.vim



~/.local/share/nvim/site



. , . Neovim :







call plug#begin('~/.vim/bundle') "     
"    
call plug#end() "  
      
      





. :







Plug '/' "    
"    ...
"...    :PlugInstall   
      
      





vim-plug , , , . , , . / , .









...











, , , 90% — . , , . .







(MacVim) :

















. . , Sublime Text — Monokai, .







...
Plug 'ErichDonGubler/vim-sublime-monokai' "    
...

colorscheme sublimemonokai "     
      
      





( ), . , Darcula, Solarized Dark ...

















status bar. , tmux WM , . Airline:







...
Plug 'vim-airline/vim-airline' "  
...

"   
let g:airline_powerline_fonts = 1 "  Powerline 
let g:airline#extensions#keymap#enabled = 0 "   
let g:airline_section_z = "\ue0a1:%l/%L Col:%c" "   
let g:Powerline_symbols='unicode' " unicode
let g:airline#extensions#xkblayout#enabled = 0 "   
      
      





Powerline , , , — , . Keymap , ( ). \ue0a1



— "ln", , .







Airline :













:

















, . , gui Powerline. , :







"16        
set guifont=____:h16
      
      





. -, . , — Fira Code, ( ). -, Devicons, Airline Nerdtree ( ) .







...
Plug 'ryanoasis/vim-devicons' "      
...
      
      





.













, Powerline , Nerd Font, Fira Code . , MacOS brew :







#  
brew tap homebrew/cask-fonts
brew cask install font-firacode-nerd-font
      
      





( GUI. , "" ):







set guifont=Fura\ Code\ Light\ Nerd\ Font\ Complete:h16 " light 
      
      





:

















. ( :help



)
( ). , :







set guioptions= "    GUI
set showtabline=0 "   ( FTW)

"   number    
"relativenumber -     
set number relativenumber "   .  

"wrap      
" nowrap     
set wrap linebreak nolist "    wrap...
"...     ,   

"    soft wrapping
"       ...
"...      :
set textwidth=80 " 80       

set cursorline "       

"     ,   NeoVim, ...
"...        :
set ttimeoutlen=10 "   escape 
let &t_SI.="\e[5 q" "SI =  
let &t_SR.="\e[3 q" "SR =  
let &t_EI.="\e[1 q" "EI =  
" 1 -   
"2 -  
"3 -  
"4 -  
"5 -   
"6 -   

set macligatures "    MacVim
"    
      
      







?



, , — . , - , , , .







. , . — , . , ( ) .







, . , gVim MacVim, ( ). :









Langmap



, , :







set langmap=;ABCDEFGHIJKLMNOPQRSTUVWXYZ,;abcdefghijklmnopqrstuvwxyz
      
      





. . , , .









Keymap



:







"    qwerty,   mac  win
set keymap=russian-jcukenmac
"     - 
set iminsert=0
"   
set imsearch=0
      
      





, — … <C-^>



… , . , , .







, , . , , ( ) Keymap .









Xkb-switch



. . Xkb-switch , , , MacOS. .







#     
git clone https://github.com/myshov/xkbswitch-macosx
#        $PATH
cp xkbswitch-macosx/bin/xkbswitch /usr/local/bin/xkbswitch
#     -  
git clone https://github.com/myshov/libxkbswitch-macosx
cp libxkbswitch-macosx/bin/libxkbswitch.dylib /usr/local/lib/libxkbswitch.dylib
      
      





:







...
Plug 'lyokha/vim-xkbswitch'
...

let g:XkbSwitchEnabled = 1 " 
      
      





. . Airline, Xkb-switch? , ( ) , .







. Xkb-switch , , vice versa. . .











, .









...









Slime



, — Slime. Ctrl-C-C, REPL . :







...
Plug 'jpalardy/vim-slime'
...
      
      





, , Slime screens , . , tmux (, ). :







" tmux
let g:slime_target = "tmux"

"  
let g:slime_target = "vimterminal"

"  
let g:slime_target = "neovim"
      
      







Jupyter



, . Jupyter — iPython, matplotlib. notebook lab, — .







… , , Jupyter:







jupyter qtconsole --generate-config
vim ~/.jupyter/jupyter_qtconsole_config.py
      
      











#c.ConsoleWidget.include_other_output = False
      
      





, False True.







Jupyter-vim:







...
Plug 'jupyter-vim/jupyter-vim'
...
      
      





, Python ( ), ( ## #%%) Jupyter. :







jupyter qtconsole &
      
      











:JupyterConnect "  ,   
      
      





\X ( \ — <localleader>



)
Jupyter , , \R . .







, . , :







nnoremap <leader>jc :call jupyter#Connect()<CR> " 
      
      





Jupyter , . , , , .







, , . , — .









LaTeX



, , . "" " " — (, ?). , .







, , ? , LaTeX! , , . Vimtex.







...
Plug 'lervag/vimtex'
...

let g:tex_flavor = 'latex' "  

"    Quickfix
let g:vimtex_quickfix_mode = 0
      
      





, .tex <localleader>ll



( :VimtexCompile



)
, , Quickfix Location , pdf.







MacOS Preview . Zathura, , . :







#     MacOS (   XQuartz)
brew tap zegervdv/zathura
brew install zathura --with-synctex
brew install zathura-pdf-poppler

#   (   )
mkdir -p $(brew --prefix zathura)/lib/zathura
ln -s $(brew --prefix zathura-pdf-poppler)/libpdf-poppler.dylib $(brew --prefix zathura)/lib/zathura/libpdf-poppler.dylib

#     
#     Vimtex
#     
brew install xdotool
      
      





Vimtex zathura :







let g:vimtex_view_method = 'zathura'
      
      





Linux pdf. , : Vim <C-z>



, zathura _.pdf &



fg



.













, ~/.config/zathura/zathurarc



(, )







set recolor true
set recolor-darkcolor "#dcdccc"
set recolor-lightcolor "#1f1f1f"
      
      







Markdown



, LaTeX . . Markdown.







Markdown ( " ") — , HTML. ( ). , , — .







Livedown. — vimtex markdown. . Nodejs :







#   MacOS
brew install node
# 
npm install -g livedown
      
      





:







...
Plug 'shime/vim-livedown'
...

"      
nnoremap <leader>ld :LivedownToggle<CR>
      
      





<leader>ld



( ) . , HTML , , markdown , "" .







, markdown — . Markdown-preview. , Livedown, ( ). , .











, , () . , , :

















. — , . , .







Vim, Sublime Text . . , .







, gdb, lldb .











:make



, . , , , ( ).







, YouCompleteMe , Neomake:







...
Plug 'Valloric/YouCompleteMe'
Plug 'neomake/neomake'
...
" ,  YCM     
": python3 ~/.vim/bundle/YouCompleteMe/install.py --clang-completer

let g:ycm_show_diagnostics_ui = 0 " YCM

"     Neomake
let g:neomake_cpp_clang_maker = {
   \ 'exe': 'clang++',
   \ 'args': ['-I/usr/local/include/wx-3.0', '-std=c++17'],
   \ }
      
      









<C-]>



, . . ctags:







#     
ctags -R &
      
      





, ( YCM):







"       :
:YcmCompleter GoToDeclaration
      
      





, — . . ...











. , .







( , ). , , . 8 ( NeoVim ) API . , , .







AsyncRun. Vim 8, NeoVim ( ).







...
Plug 'skywind3000/asyncrun.vim'
...

nnoremap <F3> :AsyncRun ctags -R<CR>
      
      





F3 ctags. AsyncRun



Quickfix. AsyncStop



.







, zathura :







:AsyncRun zathura mew.pdf
      
      







Git



Git, . IDE , , , . - Fugitive, .







, , , . :Gfetch



:Gpush



:Make



, :







command! -bang -nargs=* -complete=file Make AsyncRun -program=make @ <args>
      
      









, IDE , , , . , , . , , , - . .







, , ( NeoVim) ...













,







  1. ,
  2. VimAwesome
  3. Reddit



All Articles