[BangPypers] BangPypers Digest, Vol 8, Issue 15

Siddharta siddharta.lists at gmail.com
Tue May 6 04:09:35 CEST 2008


I used to be a heavy vim user for python, but now I use Wing IDE. I've 
tried out a number of free IDEs - SPE, Eric3, Scite, Pydev and plain old 
vim - and Wing is just way better. Its not free, but its worth it, 
especially if you do a lot of python programming involving multiple 
files - http://www.wingide.com/wingide/index
--
Siddharta Govindaraj

Anand Balachandran Pillai wrote:
> All right. Since vimmers are on a roll, Emacs-ians cannot be left behind ;)
>
> Here are the customizations for emacs.
>
> First you need "python-mode" for editing Python code. Get it from
> http://sourceforge.net/projects/python-mode/  and put the python-mode.el
> file in some directory which is part of your Emacs "load-path" variable.
>
> Now, in your .emacs file, add the following lines
>
> ;; These make sure that when you open a Python file
> ;; the python-mode is loaded automatically
> (add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
> (add-to-list 'auto-mode-alist '("\\.pyw$" . python-mode))
>
> ;; A set of prog-modes which require tabs, example, Makefiles.
> (setq tabify-modes '(makefile-gmake-mode))
>
> ;; Convert tabs to spaces and saves the buffer
> (defun untabify-save-buffer()
>   (interactive)
>   (if (not (member major-mode tabify-modes))
>       (untabify (point-min) (point-max)))
>   (save-buffer))
>
> Bind the function "untabify-save-buffer" to some convenient key.
> I have bound it to F2. Then press the short-cut key everytime to
> save an  edited buffer to disk.
>
> (global-set-key [f2] 'untabify-save-buffer)
>
> That's it. Keep using tabs to format your Python source code
> and at the end hit F2 to save the buffer and emacs takes care
> of the rest.
>
> As an added customization, you could make sure you remove
> any additional Ctrl-Ms which are seen when you open a file edited
> in DOS/Windows in Unix.
>
> ;; Remove all Ctrl-Ms from a region
> (defun ^m-region (min max)
>   "Remove all ^M's from the region."
>   (interactive "r")
>   (save-excursion
>     (goto-char max)
>     (while (re-search-backward "\C-m$" min t)
>       (delete-char 1))))
>
> ;; Remove all Ctrl-Ms from a buffer
> (defun ^m-buffer ()
>   "Remove all ^M's from the buffer."
>   (interactive)
>   (^m-region (point-min) (point-max)))
>
> Then you could define an umbrella function which performs both
> Ctrl-M removal and untabification in one, something like,
>
> (defun ^m-untabify-save-buffer()
>   (interactive)
>   (^m-buffer)
>   (untabify-save-buffer))
>
> And bind it to a global key.
>
> (global-set-key [f2] '^m-untabify-save-buffer)
>
> Ah, the beauties of Elisp...
>
> Regards
>
> --Anand
>
> On Mon, May 5, 2008 at 4:27 PM, Kiran Jonnalagadda <jace at pobox.com> wrote:
>   
>> On 02-May-08, at 11:46 AM, Biju Chacko wrote:
>>
>>
>>     
>>> If you are a vim user you can add:
>>>
>>> set expandtabs
>>>
>>> to your .vimrc to ensure that vim indents with only spaces.
>>>
>>>       
>>  I'd recommend being more elaborate:
>>
>>  set et    " Expand tabs
>>  set ai    " Auto-indent
>>  set sw=4  " Indent to 4 spaces
>>  set ts=8  " Treat tabs as 8 columns
>>  set si    " Smart indent
>>  set sta   " Smart tab key handling
>>  syn on    " Make syntax visible
>>
>>  " Make tabs visible if you're running gvim
>>  if has("gui_running")
>>     set lcs=tab:»·,trail:·,extends:»,precedes:«
>>  endif
>>
>>
>>  _______________________________________________
>>  BangPypers mailing list
>>  BangPypers at python.org
>>  http://mail.python.org/mailman/listinfo/bangpypers
>>     


More information about the BangPypers mailing list