You are not logged in.
Pages: 1
I am only just trying to learn Python. Presently using IDLE, but I prefer to edit with Vim. There is a lot of info around on using Vim with Python, but basically all I want to do at the moment is write a bit of test code and then run it through the Python interpreter and get back into Vim after seeing the error messages (;-)) ...I have just been doing a ":!/usr/bin/python %" for that.
Can anyone suggest a more useful Vim addon IDE that is not too convoluted or complicated?
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
au FileType python map <F5> :!clear && python %<CR>
adding this bind to your ~/.vimrc will let you simply hit F5 to run the current file.
EDIT: Just found this page, might be useful, I'm going to try it out right now myself.
http://vim.wikia.com/wiki/Python_-_chec … run_script
Last edited by splittercode (2010-07-27 02:17:03)
Offline
Great! Nice find and also your little bind works a treat.
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
While using vim as a python IDE I found this very useful for checking my style:
autocmd BufRead,BufNewFile *.py setlocal makeprg=pep8\ --ignore=E501\ %
autocmd BufRead,BufNewFile *.py setlocal efm=%f:%l:%c:\ %m
autocmd BufRead,BufNewFile *.py nmap <F9> :make<CR>
You need pep8, I think it is in AUR. It will use vim's error window thingy. Alternatively you can use pylint, which also discovers coding errors, but is more harsh than pep8.
There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.
Offline
This page, while a bit dated, has a pretty good list of guidelines you can use.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
you could also try the vim plugin 'conque' which will let you run python in a new buffer inside of vim.
Offline
what I used to do was to have a python session running inside screen and mapped some keys to send a selected region to the interpreter. (I took it from some web page, can't remember where.)
I have something like this in my .vimrc:
function Send_to_Screen(text)
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
call Screen_Vars()
end
echo system("screen -S " . g:screen_sessionname . " -p " . g:screen_windowname . " -X s\
tuff '" . substitute(a:text, "'", "'\\\\''", 'g') . "'")
endfunction
function Screen_Session_Names(A,L,P)
return system("screen -ls | awk '/Attached/ {print $1}'")
endfunction
function Screen_Vars()
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
let g:screen_sessionname = ""
let g:screen_windowname = "0"
end
let g:screen_sessionname = input("session name: ", "", "custom,Screen_Session_Names")
let g:screen_windowname = input("window name: ", g:screen_windowname)
endfunction
"common send to screen functions
vmap <C-c><C-c> "ry :call Send_to_Screen(@r)<CR>
nmap <C-c>v :call Screen_Vars()<CR>
"python : insert tags and send fns
nmap <C-i><C-p> i#{<CR>#}
nmap <C-c><C-p> ml?#{<CR>jv/#}<CR>k<C-c><C-c>`l
as you can see <C-i><C-p> would insert a couple of tags #{ #} then you write the code in between and, then doing <C-c><C-p> would send everything between the #{ ... #} to python. Very useful when you want to test just some pieces of code, instead if the whole file.
Offline
Pages: 1