- Unzipped the contents of pyflakes-vim.zip to
vimfiles/ftplugin - Added
runtime ftplugin/pyflakes.vimto myvimfiles/ftplugin/python.vimscript
Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts
Sunday, May 31, 2009
Pyflakes Vim Script for Python Editing
I found another very useful Vim script for editing Python code: pyflakes.vim. It basically gives you on-the-fly code checking, similar to Eclipse: "pyflakes-vim shows wavy underlines underneath common Python errors like misspelling a variable name. It also warns about unused imports, redefined functions, etc.". It's not perfect in it's analysis, but it sure helps catch a lot of errors that normally don't get caught until runtime.
I didn't follow the installation instructions since I generally load my file type scripts explicitly, and because I couldn't get the script to load using the instructions given. Instead I did the following:
Wednesday, March 4, 2009
Vim Scripts I Use When Editing Python Source
Following are some public vim scripts I have found the most useful for editing python source files:
- ftplugin/python_fn.vim -- A set of shortcuts and menus to move around and select code blocks
- ftplugin/python_ifold.vim -- Smart folding
- ftplugin/pydoc.vim -- View Python's online help in a vim window
- ftplugin/pythoncomplete.vim --Omni complete
- syntax/python.vim -- Enhanced Python syntax highlighting
- plugin/taglist.vim -- Source code browser
- plugin/NERD_commenter.vim --Easy commenting/uncommenting lines of code
- plugin/NERD_tree.vim -- Integrated file/folder browser; entries are displayed in a tree style
- plugin/pyflakes.vim -- Highlights common Python errors
Wednesday, February 11, 2009
Compiling Vim (on Windows) To Use Different Python Versions
I recently wanted to use Python Omni Complete for Vim, but whenever I executed the complete command <c-x><c-o> it failed with the error:
Following is one way to compile Vim to use a different version of Python than that shipped with Vim. I targeted 2.6, but the steps can be tweaked to work for any version of Python. It is assumed Vim and Python are already installed.
Error: Required vim compiled with +python
E117: Unknown function: pythoncomplete#Complete
This is incorrect. After doing a :version command, Vim showed it was compiled for Python support (the +python/dyn option was present). The real problem was Vim could not find the correct version of Python it was expecting: I had 2.6 installed, Vim wanted 2.4 (DYNAMIC_PYTHON_DLL="python24.dll").Following is one way to compile Vim to use a different version of Python than that shipped with Vim. I targeted 2.6, but the steps can be tweaked to work for any version of Python. It is assumed Vim and Python are already installed.
- Obtain a C++ compiler. I considered two, GCC from Cygwin and GCC from MinGW. I went with the latter simply because it was easy to install only the C/C++ development tools (e.g. GCC, make) that I needed. The Cygwin installer had far too many packages to chose from. I didn't want to waste my time determining what was necessary to install from packages I had no interest in.
- Obtain Vim source code and unzip somewhere, say
C:\. - Edit the MinGW make file. For me that is
C:\vim\vim72\src\Make_ming.mak. Find the variablePYTHON_VERand set the version number to whatever version of Python you have installed. Also, find the variablePYTHONand set to the root of the Python installation directory. In my case,
PYTHON=c:/Programs/Python26 PYTHON_VER=26 - MinGW did not add the location of the GNU make tool to my
PATH, so I had to manually do that next. Since I had no intentions of using this tool after I was done compiling Vim, I updated my path temporarily. To do that, I opened a command prompt in the directory of the make file (C:\vim\vim72\src) and executed
whereset PATH=%PATH%;C:\Programs\MinGW\binC:\Programs\MinGWis the location where I installed MinGW. - Compile GVim. Using the same command prompt window in which
PATHwas changed, execute
Normally you would executemingw32-make -f Make_ming.mak gvim.exemake -f Make_ming.mak gvim.exe, butmake.exeseems to have been renamed tomingw32-make.exein the MinGW installation. - Install gvim.exe. After compiling is done, locate
gvim.exein the same directory as the make file (C:\vim\vim72\src) and copy to Vim's runtime directory. For my,C:\Program Files\Vim\vim72. There should already be agvim.exethere. - Make sure the Python 2.6 installation is on your path, namely the directory where Python26.dll is located.
Subscribe to:
Posts (Atom)