Text Editors

Text-editing, the main tool for developers.

Vim

Install:

sudo apt-get -qy install \
  git \
  vim-gtk

The above get’s us vim and git to install vim-plugins. The following are dependencies for plugins, installing them ahead of time:

sudo apt-get -qy install \
  build-essential \
  cmake \
  default-jdk \
  golang \
  mono-complete \
  nodejs \
  npm \
  python3-dev \
  vim-nox

Configuration

Create directory layout and initial configuration file:

mkdir .vim
touch .vimrc

Plugin Manager

vundle or pathogen:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Provide the plugin-manager configuration as the first thing in your .vimrc:

  1set nocompatible              " be iMproved, required
  2filetype off                  " required
  3
  4" ==== Plugin-Manager: vundle -- begin ============================================================
  5" Brief help: {PluginList, PluginInstall, PluginClean}
  6" set the runtime path to include Vundle and initialize
  7set rtp+=~/.vim/bundle/Vundle.vim
  8call vundle#begin()
  9
 10Plugin 'VundleVim/Vundle.vim'
 11
 12Plugin 'flazz/vim-colorschemes'
 13Plugin 'powerline/fonts'
 14Plugin 'tpope/vim-fugitive'
 15Plugin 'vim-airline/vim-airline'
 16Plugin 'vim-airline/vim-airline-themes'
 17Plugin 'ludovicchabant/vim-gutentags'
 18Plugin 'kien/ctrlp.vim'
 19Plugin 'valloric/youcompleteme'
 20
 21" Unused plugins
 22"Plugin 'scrooloose/syntastic'
 23"Plugin 'nathanaelkane/vim-indent-guides'
 24
 25" All of your Plugins must be added before the following line
 26call vundle#end()            " required
 27" ==== Plugin-Manager: vundle -- end ==============================================================
 28filetype plugin indent on    " required
 29" ==== Plugin-Configuration:-- begin ==============================================================
 30
 31" ==== vim-airline
 32let g:airline_theme='solarized'
 33let g:airline_solarized_bg='dark'
 34let g:airline_powerline_fonts=1
 35"let g:airline_statusline_ontop=1
 36
 37" ==== Plugin-Configuration -- end ================================================================
 38
 39" ==== General Configuration ======================================================================
 40set number                      "Line numbers are good
 41set backspace=indent,eol,start  "Allow backspace in insert mode
 42set history=1000                "Store lots of :cmdline history
 43set showcmd                     "Show incomplete cmds down the bottom
 44set showmode                    "Show current mode down the bottom
 45set gcr=a:blinkon0              "Disable cursor blink
 46
 47" ==== Enable syntax high-light ===================================================================
 48syntax on
 49let g:solarized_termcolors=16
 50set t_Co=16
 51set background=dark
 52colorscheme solarized
 53
 54" ==== Reload files changed outside vim ===========================================================
 55set autoread
 56
 57" This makes vim act like all other editors, buffers can
 58" exist in the background without being in a window.
 59" http://items.sjbach.com/319/configuring-vim-right
 60set hidden
 61
 62" ==== Scrolling ==================================================================================
 63" = Start scrolling when 'scrollloff' lines away from top/bottom
 64" = and 'sidescrollloff' characters from top/bottom
 65set scrolloff=8
 66set sidescrolloff=15
 67set sidescroll=1
 68
 69" ==== Turn Off Swap Files ========================================================================
 70set noswapfile
 71set nobackup
 72set nowb
 73
 74" ====  Persistent Undo ===========================================================================
 75" Keep undo history across sessions, by storing in file.
 76" Only works all the time.
 77if has('persistent_undo')
 78  silent !mkdir ~/.vim/backups > /dev/null 2>&1
 79  set undodir=~/.vim/backups
 80  set undofile
 81endif
 82
 83" ==== Indentation ================================================================================
 84set autoindent
 85set smartindent
 86set smarttab
 87set shiftwidth=8
 88set softtabstop=8
 89set tabstop=8
 90
 91" ==== Indentation: file-specific =================================================================
 92autocmd BufEnter *.css :setlocal filetype=html
 93autocmd BufEnter *.cu :setlocal filetype=cpp
 94autocmd BufEnter *.h :setlocal filetype=c
 95autocmd BufEnter *.html :setlocal filetype=html
 96autocmd BufEnter *.js :setlocal filetype=html
 97autocmd BufEnter *.json :setlocal filetype=html
 98autocmd BufEnter *.plan :setlocal filetype=yaml
 99autocmd BufEnter *.preseed :setlocal ts=4 sw=4 expandtab
100autocmd BufEnter *.sh :setlocal ts=2 sw=2 expandtab
101autocmd BufEnter *.suite :setlocal filetype=shell
102autocmd Filetype c setlocal ts=8 sw=8 textwidth=99 noexpandtab
103autocmd Filetype cpp setlocal ts=2 sw=2 expandtab
104autocmd Filetype html setlocal ts=2 sw=2 expandtab textwidth=99
105autocmd Filetype js setlocal ts=2 sw=2 expandtab textwidth=99
106autocmd Filetype markdown setlocal ts=4 sw=4 expandtab
107autocmd Filetype python setlocal ts=4 sw=4 textwidth=88 autoindent fileformat=unix expandtab
108autocmd Filetype rst setlocal ts=2 sw=2 expandtab textwidth=79 wrapmargin=0 formatoptions=nt
109autocmd Filetype ruby setlocal ts=2 sw=2 expandtab
110autocmd Filetype shell setlocal textwidth=0 wrapmargin=0
111autocmd Filetype yaml setlocal ts=2 sw=2 expandtab
112
113" ==== Indentation: display tabs and trailing spaces visually =====================================
114set list listchars=tab:»·,trail:·,extends:$,nbsp:=
115set nowrap       "Don't wrap lines
116set linebreak    "Wrap lines at convenient points
117
118" ==== Redrawing ==================================================================================
119set lazyredraw
120set ttyfast
121
122" ==== yank to clipboard ==========================================================================
123set clipboard=unnamedplus
124set clipboard^=unnamed
125
126" ==== Wrapping ===================================================================================
127set formatoptions+=t colorcolumn=+1 tw=80
128set formatoptions+=t colorcolumn=+1 tw=99
129
130" ==== Display tabs and trailing spaces visually ==================================================
131set list listchars=tab:»·,trail:·,extends:$,nbsp:=
132
133" ==== Use vim-built-in file-browser (netrw) in a NERDTree-like fashion ===========================
134nmap <silent> <f2> :Lexplore<cr>
135let g:netrw_altv = 1
136let g:netrw_banner = 0
137let g:netrw_browse_split = 4
138let g:netrw_liststyle = 3
139let g:netrw_winsize = 25
140
141" ==== tags: search upwards for tags file ===========
142set tags=~/tags/xnvme,~/tags/spdk,./tags;/
143
144" ==== Disabled options ===========================================================================
145" set visualbell                  "No sounds

Then install the plugin-manager, by running the following command inside vim:

:PluginInstall

Code-Completion

Go ahead, build and install YouCompleteMe(YCM):

cd ~/.vim/bundle/youcompleteme
# For c only
#python3 install.py --clangd-completer
python3 install.py --all

Clipboard