I think I came up with a solution. Made a file called 'pythonft.vim' in ftdetect/ with this content:
au BufNewFile,BufRead *.py set filetype=python au BufNewFile,BufRead *.py so ~/.vim/macros/python_macros.vim I then defined the shortcut in python_macros.vim: map <buffer> π :w <CR>:!python % <CR> It seems to be working now. Thanks Peiman On 11 May 2013 10:39, peiman khosravi <[email protected]> wrote: > Hello, > > Thanks for the reply. I tried your suggestion but it doesn't seem to make > a difference. I've pasted the content of my .vimrc file below. > > Thanks > Peiman > > > " Configuration file for vim > set modelines=0 " CVE-2007-2438 > > " Normally we use vim-extensions. If you want true vi-compatibility > " remove change the following statements > set nocompatible " Use Vim defaults instead of 100% vi compatibility > set backspace=2 " more powerful backspacing > > " Don't write backup file if vim is being called by "crontab -e" > au BufWrite /private/tmp/crontab.* set nowritebackup > " Don't write backup file if vim is being called by "chpass" > au BufWrite /private/etc/pw.* set nowritebackup > > set ai " auto indenting > set history=100 " keep 100 lines of history > set ruler " show the cursor position > syntax on " syntax highlighting > set hlsearch " highlight the last searched term > filetype plugin on " use the file type plugins > set nofoldenable > colorscheme murphy > > map <buffer> π :w <CR>:!python % <CR> > if exists('*<SID>Python_jump') | finish | endif > > " When editing a file, always jump to the last cursor position > " autocmd BufReadPost * > " \ if ! exists("g:leave_my_cursor_position_alone") | > " \ if line("'\"") > 0 && line ("'\"") <= line("$") | > " \ exe "normal g'\"" | > " \ endif | > " \ endif > " > > > > > > > > *www.peimankhosravi.co.uk* || Subscribe to RSS > Feed<http://peimankhosravi.co.uk/miscposts.rss> > > *To receive emails about upcoming concerts visit this > page<http://spectralkimia.wordpress.com/>& enter your email address in the > 'follow' section. > * > > > On 10 May 2013 09:39, huubby zhou <[email protected]> wrote: > >> I guess you add the map at the end of python.vim, is that correct? >> >> If so, I suggest you move your map command to before >> if exists('*<SID>Python_jump') | finish | endif >> >> If no, please give your python.vim. >> >> >> On Thu, May 9, 2013 at 8:35 PM, peiman khosravi <[email protected] >> > wrote: >> >>> Hello, >>> >>> I'm experiencing something odd. Is it a bug or my lack of knowledge? >>> >>> I open a new window (cmnd-n). I type ':e python.py' and paste a bit of >>> code in there, which I have copied from another document. The syntax is >>> highlighted and all is good. >>> >>> I then press alt-p, which is a shortcut I have defined in my >>> /vim/plugin/python.vim file ("map <buffer> π :w <CR>:!python % <CR>"). >>> >>> Result: Nothing happens. >>> >>> I save the file and try again: nothing happens. >>> >>> I reopen the file, and the shortcut is now working. Am I doing something >>> wrong? >>> >>> Many Thanks >>> Peiman >>> >>> -- >>> -- >>> You received this message from the "vim_mac" maillist. >>> Do not top-post! Type your reply below the text you are replying to. >>> For more information, visit http://www.vim.org/maillist.php >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "vim_mac" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> -- >> You received this message from the "vim_mac" maillist. >> Do not top-post! Type your reply below the text you are replying to. >> For more information, visit http://www.vim.org/maillist.php >> >> --- >> You received this message because you are subscribed to the Google Groups >> "vim_mac" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- -- You received this message from the "vim_mac" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_mac" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
