Created
December 29, 2010 16:44
-
-
Save kmpm/758719 to your computer and use it in GitHub Desktop.
Script to get a basic setup of vim for python on ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This file fairly close follows the recommendations in | |
# http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/ | |
# | |
#MIT/Expat License | |
#Copyright (C) 2010 by Peter Magnusson <peter[at]birchroad.net> | |
# | |
#Permission is hereby granted, free of charge, to any person obtaining a copy | |
#of this software and associated documentation files (the "Software"), to deal | |
#in the Software without restriction, including without limitation the rights | |
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
#copies of the Software, and to permit persons to whom the Software is | |
#furnished to do so, subject to the following conditions: | |
# | |
#The above copyright notice and this permission notice shall be included in | |
#all copies or substantial portions of the Software. | |
# | |
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
#THE SOFTWARE. | |
# | |
VIMRC=$HOME/.vimrc | |
VIM_FOLDER=$HOME/.vim | |
FTPLUGIN_FOLDER=$VIM_FOLDER/ftplugin | |
INDENT_PYTHON_VIM=$VIM_FOLDER/indent/python.vim | |
SYNTAX_PYTHON_VIM=$VIM_FOLDER/syntax/python.vim | |
NERD_ZIPFILE=/tmp/NERD_tree.zip | |
VIMSCRIPT_URL=http://www.vim.org/scripts/download_script.php | |
echo " | |
This script will install the packages... | |
vim vim-scripts vim-nox vim-python pylint pyflakes unzip | |
...in order to run vim as we like and _unzip_ to deflate | |
a script during the procedure. | |
It is recommended to backup .vimrc and .vim/ before | |
you continue just in case anything goes bad since the | |
script modifies these files and paths heavily. | |
If you chose not to remove any current vim settings | |
things might behave strangely. | |
THIS SOFTWARE IS PROVIDED ''AS IS'' AND WITHOUT ANY EXPRESS OR | |
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
" | |
#Cleanup | |
read -p "Remove all vim settings first? [yes/no]? " answer | |
if [ "$answer" = yes ]; then | |
echo "removing ~/.vimrc ~/.vim/" | |
rm $VIMRC | |
rm $INDENT_PYTHON_VIM | |
rm $SYNTAX_PYTHON_VIM | |
rm $FTPLUGIN_FOLDER/python*.vim | |
fi | |
echo " | |
Will now install the vim vim-scripts vim-nox vim-python pylint pyflakes unzip packages and you might have to provide a password for sudo | |
" | |
sudo aptitude install vim vim-scripts vim-nox vim-python pylint pyflakes unzip | |
mkdir -p $VIM_FOLDER/indent | |
mkdir -p $VIM_FOLDER/syntax | |
mkdir -p $VIM_FOLDER/ftplugin | |
#basic .vimrc stuff | |
echo " | |
syntax on | |
filetype plugin indent on | |
python << EOF | |
import vim | |
EOF | |
map <F2> :NERDTreeToggle<CR> | |
" >>$VIMRC | |
#python indenting and code complete | |
echo " | |
setlocal tabstop=4 | |
setlocal softtabstop=4 | |
setlocal shiftwidth=4 | |
setlocal textwidth=80 | |
setlocal smarttab | |
setlocal expandtab | |
\"\" change the colorscheme to whatever fitts you | |
colorscheme koehler | |
\"\" Syntax and code completion | |
set complete+=k~/.vim/syntax/python.vim isk+=.,( | |
" >> $FTPLUGIN_FOLDER/python.vim | |
#indent file | |
wget --output-document=$INDENT_PYTHON_VIM $VIMSCRIPT_URL?src_id=4316 | |
#syntax file | |
wget --output-document=$SYNTAX_PYTHON_VIM $VIMSCRIPT_URL?src_id=12804 | |
#python ipdb file | |
wget --output-document=$FTPLUGIN_FOLDER/python_ipdb.vim http://www.cmdln.org/wp-content/uploads/2008/10/python_ipdb.vim | |
#python folding file | |
wget --output-document=$FTPLUGIN_FOLDER/python_folding.vim $VIMSCRIPT_URL?src_id=5492 | |
#python block navigation | |
wget --output-document=$FTPLUGIN_FOLDER/python_fn.vim $VIMSCRIPT_URL?src_id=9196 | |
#python NERD Tree | |
wget --output-document=$NERD_ZIPFILE $VIMSCRIPT_URL?src_id=11834 | |
unzip $NERD_ZIPFILE -d $VIM_FOLDER | |
echo " | |
Vim is now tweeked for Python. Some highlights are... | |
* proper indenting | |
* insert ipdb debug line with F7 | |
* remove all debug lines <shift> + F7 | |
* fold / unfold <shift> + f | |
* NERD Tree :helptags :help NERD_tree.txt | |
* NERD Tree toggle F2 | |
* koehler colorscheme by default | |
This file fairly close follows the recommendations in | |
http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/ | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment