VIM Notes

VIM Notes


Last Updated: December 31, 2018 by Pepe Sandoval



Want to show support?

If you find the information in this page useful and want to show your support, you can make a donation

Use PayPal

This will help me to create more stuff and fix the existent content... or probably your money will be used to buy beer


vim

vim setup

  1. Install vim and gvim
    • sudo apt-get install vim
    • sudo apt-get install vim-gnome
  2. Install Vundle (Vim Plugin manager)
    • Clone Vundle repo: git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  3. create a new file in the .vim folder (touch vundle-vimrc.vim) and add the following lines to it:

     set nocompatible  " be iMproved, required
     filetype off  " required
    
     " set the runtime path to include Vundle and initialize
     set rtp+=~/.vim/bundle/Vundle.vim
     call vundle#begin()
     " alternatively, pass a path where Vundle should install plugins
     "call vundle#begin('~/some/path/here')
    
     " let Vundle manage Vundle, required
     Plugin 'VundleVim/Vundle.vim'
     " ADD PLUGINS AFTER THIS COMMENT. Use Plugin 'plugin_path'
    
     " All of your Plugins must be added before the following line
     call vundle#end()" required
     filetype plugin indent on" required
     " To ignore plugin indent changes, instead use:
     "filetype plugin on
     "
     " Brief help
     " :PluginList   - lists configured plugins
     " :PluginInstall- installs plugins; append `!`
     " :PluginUpdate - to update
     " :PluginSearch foo - searches for foo; append `!` to refresh local cache
     " :PluginClean  - confirms removal of unused plugins; append `!` to auto-approve removal
     "
     " see :h vundle for more details or wiki for FAQ
     " Put your non-Plugin stuff after this line
  4. in the .vimrc add the following line:

    • source ~/.vim/vundle-vimrc.vim

        "Add Vundle config"
        source ~/.vim/vundle-vimrc.vim
      
        " Color-specific
        " examples 'bg=light'
        "colorscheme darkblue
        "set bg=dark
      
        " Turn on syntax coloring and line numbering.
        " Enable highlighting all search results.
        syn on
        set nu
        set hlsearch
      
        " Intentation settings.
        set tabstop=4
        set expandtab
        set shiftwidth=4
        set smartindent
      
        " Auto-wrap lines at X number of characters.
        set tw=100
      
        " Allow Vim to detect the filetype, useful for certain plugins.
        filetype plugin on
      
        " Tells Vim where to find cscope.
        set csprg=/usr/bin/cscope
      
        set number

if you don't have a .vimrc on your home(~/) directory create one (vim ~/.vimrc)

vim Plugins

Add Plugins to your vundle vim file, this means edit the vundle-vimrc.vim we created

NERDTree

File explorer in vim

  • Plugin 'jistr/vim-nerdtree-tabs'
  • Plugin 'scrooloose/nerdtree'

ctag

Indexing/navigation tags

  • Plugin 'xolox/vim-easytags'
  • Plugin 'xolox/vim-misc'
  • Install the exuberant-ctags package, use sudo apt-get install exuberant-ctags

vim-airline

Status bar for vim

  • Plugin 'bling/vim-airline'

taglist

Tag explorer for vim

  • Plugin 'taglist.vim'

    commands on vim
    • TlistToggle

To install plugins from the terminal execute vim +PluginInstall +qall to install the plugins

vim commands

  1. x: Delete character
  2. dw: delete characters until end of word from current cursors pos
  3. dd: Delete current line
  4. d$: Delete from current cursor pos to endline
  5. u: Undo last change
  6. ctrl+R/ctrl+r: Redo last change
  7. y: yank/copy selected lines or current line if nothing is selected
  8. p: Paste yanked/copied lines
  9. set nu : enable line numbers
  10. set wrap / set no wrap: enable/disable wrapping
Want to show support?

If you find the information in this page useful and want to show your support, you can make a donation

Use PayPal

This will help me to create more stuff and fix the existent content... or probably your money will be used to buy beer