Vim Configuration
Tags: vim, configuration, systemadministraton, config
Published: 2020-08-11 14:51:26

---
title: Vim Configuration
published: true
date: 2020-05-12 05:00:00 UTC
tags: vim,configuration,systemadministraton,config
canonical_url: https://jmoore53.com/vim/configuration/system%20administraton/config/server/2020/05/12/vim-configuration.html
---

Vim, my server editor of choice. (I prefer vscode for development on my workstation.)

## Plugins

- vim-rainbow
- powerline
- nerdtree

## ~/.vimrc

This .vimrc is pretty gross looking, but please just note the major configurations:

- Line/Relative Line
- Tabs are 4 spaces
- Typing `{` automatically generates a closing `\n}`
- NerdTree is enabled
- The theme is Solarized
- Parentheses are pretty..

```
"VIMRC Configuration

"Default configuration
"Relative Line Number
:set number
:set rnu

"Spacing
:set tabstop=4
:set shiftwidth=4
:set expandtab

"Remap..
inoremap {<cr> {<cr>}<esc>ko
inoremap ( ()<left>

"Powerline for VIM
set rtp+=/home/jack/.local/lib/python3.8/site-packages/powerline/bindings/vim
set laststatus=2
set t_Co=256

"Nerd Tree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

map <C-n> :NERDTreeToggle<CR>

"Solarized Theme
syntax enable
set background=dark
colorscheme solarized
let g:solarized_termcolors=256

"Vim-Rainbow
let g:rainbow_active = 1

let g:rainbow_load_separately = [
    \ ['*' , [['(', ')'], ['\[', '\]'], ['{', '}']] ],
    \ ['*.tex' , [['(', ')'], ['\[', '\]']] ],
    \ ['*.cpp' , [['(', ')'], ['\[', '\]'], ['{', '}']] ],
    \ ['*.{html,htm}' , [['(', ')'], ['\[', '\]'], ['{', '}'], ['<\a[^>]*>', '</[^>]*>']] ],
    \ ]

let g:rainbow_guifgs = ['RoyalBlue3', 'DarkOrange3', 'DarkOrchid3', 'FireBrick']
let g:rainbow_ctermfgs = ['lightblue', 'lightgreen', 'yellow', 'red', 'magenta']

```

## Bash Powerline

Install Powerline

```
pip install git+git://github.com/Lokaltog/powerline
wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
mv PowerlineSymbols.otf /usr/share/fonts/
fc-cache -vf /usr/share/fonts/
mv 10-powerline-symbols.conf /etc/fonts/conf.d/

```

`~/.bashrc`

```
# Powerline
export PATH="$HOME/.local/bin:$PATH"
export POWERLINE_COMMAND=powerline
export POWERLINE_CONFIG_COMMAND=powerline-config
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1

POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /home/jack/.local/lib/python3.8/site-packages/powerline/bindings/bash/powerline.sh

```

## Getting Glyphs to work when SSHing from Mac to Server

I used FIRA Code to get powerline working on the server.

In ITerm2 `command` + `,` to open preferences, `profiles` > `text` > Non ASCII Font `Fira Code` retinat font size 12.

## Links

- [Github - NerdTree](https://github.com/preservim/nerdtree)
- [Github - vim-colors-solarized](https://github.com/altercation/vim-colors-solarized)
- [Github - Powerline](https://github.com/powerline/powerline)
- [Github - vim-rainbow](https://github.com/frazrepo/vim-rainbow)
- [SO - Where is my vimrc?](https://stackoverflow.com/questions/10921441/where-is-my-vimrc-file)
- [Github Issues - Powerline for Bash](https://github.com/powerline/powerline/issues/850)
- [TecMint - Powerline](https://www.tecmint.com/powerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/)