Configuring Vim as a fast, keyboard-driven Python IDE significantly boosts developer productivity. When following standard Vim Python configuration guides on Ubuntu 16.04 (Xenial Xerus), several key adjustments are required to achieve clean PEP 8 indentation, accurate syntax highlighting, and YouCompleteMe code autocompletion.
Stack: Ubuntu 16.04 LTS • Vim 7.4 / 8.0 • Python PEP 8 indentation rules
1. Enforcing Clean PEP 8 Indentation
Add the following configuration to your ~/.vimrc to ensure 4-space indentations, soft tabs, and trailing whitespace highlighting:
" PEP 8 standard formatting for Python buffers
augroup python_indent
autocmd!
autocmd FileType python setlocal tabstop=4
autocmd FileType python setlocal softtabstop=4
autocmd FileType python setlocal shiftwidth=4
autocmd FileType python setlocal textwidth=79
autocmd FileType python setlocal expandtab
autocmd FileType python setlocal autoindent
autocmd FileType python setlocal fileformat=unix
augroup END
2. Installing YouCompleteMe on Ubuntu 16.04
Install prerequisite development libraries before compiling the YCM C-extension:
sudo apt-get install build-essential cmake python-dev python3-dev -y
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
No comments:
Post a Comment