Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Vim plug-in


May 24, 2021 Vim


Table of contents


Plug - ins

Use plug-ins to increase efficiency, changing Vim's interface, adding new commands, automatic code replenishment, integrating other programs and tools, adding other programming languages, and more.

Tip: See Vim Awesome for some popular plug-ins

Installation

Use the plug-in manager

Plug-in managers have a similar approach to installing and managing plug-ins, regardless of the platform on which Vim is run. It is a plug-in that manages other Vim plug-ins like a package manager.

  • Vundle is now the most popular Vim plug-in manager.
  • Vim-plug is a minimalist Vim plug-in manager with many features, such as on-demand plug-in loading and parallel upgrades.
  • pathogen.vim is a simple plug-in for managing Vim's runtime path.

Download from the Arch software library

There are many plug-ins under the vim-plugins category. Use pacman -Sg vim-plugins and then you can install them using pacman.

pacman -Ss vim-plugins

cscope

Cscope is an engineering browsing tool. By navigating to a word/symbol/function and calling cscope with shortcuts, you can quickly find: function calls and function definitions, etc.

Install the cscope package.

Copy the cscope preset file, which is automatically read by Vim as:

mkdir -p ~/.vim/plugin
wget -P ~/.vim/plugin http://cscope.sourceforge.net/cscope_maps.vim

Note: In Vim's 7.x version, you may need to uncomment ~/.vim/plugin/cscope_maps.vim to enable the cscope shortcut:

set timeoutlen=4000
set ttimeout

Create a file that contains a list of the files you want the cscope index (cscope can operate in many languages, and the following examples are used to find .c, .cpp, and .h_ files in .h_):

cd /path/to/projectfolder/
find . -type f -print | grep -E '\.(c(pp)?|h)$' > cscope.files

Create the data file that the cscope will read:

cscope -bq

Note: You must browse the project file from the current path, or $CSCOPE_DB to point to the cscope.out file and export it.

Default shortcuts:

 Ctrl-\ and
      c: Find functions calling this function
      d: Find functions called by this function
      e: Find this egrep pattern
      f: Find this file
      g: Find this definition
      i: Find files #including this file
      s: Find this C symbol
      t: Find assignments to

Feel free to change these shortcuts.

Taglist

Taglist provides an overview of the structure of source files, allowing you to browse source files in different languages more efficiently.

Install the vim-taglist package.

Add the following settings to the ~/.vimrc :

let Tlist_Compact_Format = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 1
nnoremap <C-l> :TlistToggle<CR>