My NeoVim Config File

set nocompatible

filetype off

" Line numbers on:
set nu

" Use 256 colors:
set t_Co=256

" Use UTF-8 by default:
set encoding=utf-8

" Remap leader key to space bar:
let mapleader = "\<space>"

"""" Plugins """"""""""""""""""""
call plug#begin()

" Folding:
Plug 'tmhedberg/SimpylFold'
" See docstrings for folded code:
let g:SimplyFold_docstring_preview=1

" PEP8 indentation
Plug 'vim-scripts/indentpython.vim'

" Matching brackets, parens, ...:
Plug 'tpope/vim-surround'

" HTML Tags (for docs see
Plug 'mattn/emmet-vim'
" Use ctrl-a+comma to activate emmet-vim (default is ctrl-y+comma)
let g:user_emmet_expandabbr_key = '<C-a>,'

" Easymotion (see
Plug 'easymotion/vim-easymotion'
" Type <leader><leader>[action] (e.g. <leader><leader>w) to invoke easymotion

" Completion:
Plug 'Valloric/YouCompleteMe'
" Ensure auto-completion window goes away when we're done with it:
let g:ycm_autoclose_preview_window_after_completion=1
" Define shortcut for goto definition:
" map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>

" vim-jedi for "IDE" functions:
Plug 'davidhalter/jedi-vim'
" disable autocompletion, since we use YCM for that:
let g:jedi#completions_enabled = 0
" open the go-to function in split, not another buffer:
let g:jedi#use_splits_not_buffers = "right"
" vim-jedi shortcuts:
" <leader>d -> go to definition
" <leader>n -> show usage of a name in the current file
" <leader>r -> rename
" K -> show documentation

" Commenting:
Plug 'scrooloose/nerdcommenter'
" nerdcommentor options:
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" For more options, see

" A couple of color scheme plugins:
Plug 'jnurmine/Zenburn'
Plug 'altercation/vim-colors-solarized'
colorscheme blue

" A file browser:
Plug 'scrooloose/nerdtree'
" Tell file browser to ignore clutter:
let NERDTreeIgnore=['\.pyc$', '\~$']
" Use F3 to toggle nerdtree:
nnoremap <silent> <F3> :NERDTreeToggle<CR>
" Search:
Plug 'kien/ctrlp.vim'

" Git integration:
Plug 'tpope/vim-fugitive'

" Status line (using Vim-Airline instead of Powerline):
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

" PEP8 formatting:
Plug 'psf/black'

" All of your Plugins must be added before the following line
call plug#end()            " required
"""" End of Plugins """""""""""""

" Specify where splits should occur:
set splitbelow
set splitright

" split navigation:
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" code folding:
set foldmethod=indent
set foldlevel=99

" For Python files:
"   four spaces for tab, line length <= 80, Unix line endings:
au BufNewFile,BufRead *.py
     \ | set tabstop=4
     \ | set softtabstop=4
     \ | set shiftwidth=4
     \ | set textwidth=79
     \ | set expandtab
     \ | set autoindent
     \ |set fileformat=unix 
" And for some other file types:
au BufNewFile,BufRead *.js, *.html, *.css
    \ set tabstop=2 \
    \ | set softtabstop=2 \
    \ | set shiftwidth=2

" If in virtual environment, tell
" nvim to use the system Python instead of the one in the venv:
" Figure out the system Python for Neovim.
" NOTE: pynvim must be installed (pip install pynvim) in each
" virtual environment where nvim will be used.
if exists("$VIRTUAL_ENV")
    let g:python3_host_prog=substitute(system("which -a python3 | head -n2 | tail -n1"), "\n", '', 'g')
    let g:python3_host_prog=substitute(system("which python3"), "\n", '', 'g')

" In addition, check if we're in a virtual environment.
" If so, activate it. Among other things, this
" allows YCM to be aware of all packages installed
" in that environment.
py3 << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
  project_base_dir = os.environ['VIRTUAL_ENV']
  activate_this = os.path.join(project_base_dir, 'bin/')
  exec(open(activate_this).read(), {'__file__': activate_this})

let python_highlight_all=1
syntax on

" If nvim is started with no file or directory named on the command line,
" or if a directory is named on the command line, start NerdTree:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif

How to Change the Leader Key in Vim

I have to look this up every time I need to do it, so I’m posting this for myself. (Of course, it would be better to keep track of my .vimrc so I wouldn’t have to do it from scratch!)

Add to your .vimrc:

let mapleader = <space> (or whatever key you want)

Installing YouCompleteMe Plugin for Vim in Ubuntu


The YouCompleteMe plugin (YCM) provides “Intellisense-like” features within Vim. Setting it up requires several steps:

  1. Install the plugin using any Vim plugin manager. For example, if you use Vundle, you would add to your .vimrc:
    • Plugin ‘Valloric/YouCompleteMe’
  2. Install development tools:
    • sudo apt install build-essential cmake python3-dev
  3. Install Ubuntu packages on which YCM depends for the programming languages you plan on using:
    1. For C and C++ support: sudo apt install clang-8 libclang1-8 clang-tools-8
    2. For C# support: sudo apt install mono-complete
    3. For JavaScript and TypeScript: sudo apt install nodejs npm
    4. For others, see the YCM documentation at
  4. Run the YCM script with flags appropriate to the above languages:
    • For C and C++: --clang-completer
    • For C#: –cs-completer
    • –ts-completer
    • For example, if you want support for all three of the above language groups, you would do:
      • cd ~/.vim/bundle/YouCompleteMe
      • python3 ./ –clang-completer –cs-completer –ts-completer

FreeBSD for a Linux Geek

I’ve been using Linux on a daily basis for about twenty years and have gotten to know its ins and outs fairly well. In the last couple of years I’ve had a FreeNAS server, which is built on FreeBSD, so I’ve had to learn a bit about that operating system.

On more than one occasion I’ve found myself unable to find things, or remember the name of the FreeBSD command I’ve needed. I often try the Linux equivalent and find it doesn’t work, or worse, it does something different on FreeBSD than on Linux.

This page holds notes of things I’ve learned to help me remember them the next time they come up.


  • Services in FreeBSD are started and stopped by script files, analogous to those used in SysVinit distributions of Linux. The scripts are located in /etc/rc.d and /usr/local/etc/rc.d.
  • The scripts are controlled by the service command. For example:
    • service django stop
    • service django restart
  • Service configuration is in the file /etc/rc.conf. For example, to configure the ntpd service to automatically start on boot, put ntpd_enable=”YES” into that file.

System Info

  • Memory usage: vmstat fre (Linux equivalent: free -h)
  • Modules loaded: kldstat (Linux equivalent: lsmod)
  • To cause modules to be loaded on boot, add <module_name>_load=”YES” to /boot/loader.conf.

Schematic for creating 3-tier JSF/JPA application in Eclipse

JPA Layer:
1. Make project

2. Make DB connection

3. Convert project to JPA project — use connection from step 2

4. Make JPA entities – give them properties
4a List them as “managed” in persistence.xml

5. Make tables

EJB (business logic) Layer:
1. Make EJB classes that manipulate JPA entities in JPA layer.

2. Annotate EJB classes as:
EntityManager em;

3. Give the EJB classes methods to be called from the View layer

View Layer (Web, specifically)
0. If faces-config.xml doesn’t exist, do Project Properties->JPA
->Project Facets

1. In faces-config.xml, make new Managed Bean classes. Give them
Session scope.

2. Annotate them with:
BookEJB bookEJB; // for example

3. Put properties in the managed bean classes that will be
bound to the fields in the web pages.

4. Make methods in the managed bean classes that will be bound to
the buttons/links etc. in the web pages. The methods should return
strings that tell the JSF engine which page to load next.

5. Make xhtml file(s). Be sure to put the following before the
Order matters.

6. Make a form. Put components in the form that are bound to the
managed bean class properties.

Installing Oracle Java on Ubuntu – summary

Each time I do this, I have to search the Web to remember where the PPA is and what packages to install, so this time I’m summarizing the steps here:

  1. Add the WebUpd8Team Java PPA:
    sudo add-apt-repository ppa:webupd8team/java
  2. Install the installer package (downloads the Oracle installer from Oracle’s repository):
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
  3. To set up required environment variables:
    sudo apt-get install oracle-java7-set-default

For details and troubleshooting tips, see:



Fixing “Failed to Create the SD Card” using Android Tools

I use Eclipse and run the ADT stuff within it. I tried to create a new Android virtual machine and kept getting the error mentioned in the title. I verified all permissions in all applicable directories, and still had no luck.

It turned out the problem was that I was running the ADT on 64-bit Linux (Mint 17, to be specific), and I needed to install a couple of 32-bit libraries. Here is the list:
libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386

Thanks to Pavel Kazlou for providing the list here:


Speeding up Android Emulator

This is a reminder of the steps required to use kvm/hardware acceleration in the Android Emulator, in case I need to re-do them.

They’re taken from here:

(The link also has instructions for Windows and Mac, in case any of you haven’t switched to Linux yet.)

In brief, the steps are:

  1. Verify hardware support by typing
    egrep –c ‘(vmx|svm)’ /proc/cpuinfo

    (result should not be 0).
  2. Install required packages:
    sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
  3. Add yourself to the kvm and libvirtd groups; log out and log in again.
  4. Install “Intel x86 Atom System Image” in Android SDK Manager
  5. (If using Eclipse, shut it down and restart it.)
  6. Create a new device in the Android Virtual Device Manager, selecting the new system image for the “CPU/ABI” option.

Adding an external Java library to an Eclipse project

I wanted to use a method from the Apache Commons Lang library in an
Eclipse project. Here’s how to do that:

1. Download the library. (The Apache Commons Lang library is found here: Select the version appropriate for your version of Java. You probably want the latest, unless you’re using an old, old version of Java. Also, get the binary rather than the source, unless you want to compile it for yourself.)

2. Create a “lib” folder in your Eclipse project. Right-click on the project name and select “New->Folder” Call the folder “lib”

3. Copy the jar into the folder you just created.

4. In Eclipse, find the jar file in the lib folder and right-click on it. Select “Build Path->Add to Build Path” The jar file will now be listed in your project under “Referenced Libraries.”