免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: mars_diy

你写python用制表符还是用空格? [复制链接]

论坛徽章:
0
发表于 2007-09-13 17:00 |显示全部楼层
Tab用不习惯,还是空格好用!!!

论坛徽章:
0
发表于 2007-10-11 18:04 |显示全部楼层
原帖由 cgxu 于 2007-9-8 20:10 发表
强力支持16楼
空格太繁琐,麻烦


一般的做法,是把编辑器设置为 自动将tab转换为四个空格。 大多数编辑器都可以做这个设定,包括vim。

何来繁琐之言?

论坛徽章:
0
发表于 2008-01-17 18:14 |显示全部楼层
绝对要空格,不然会害死你的.
realfun 该用户已被删除
发表于 2008-01-18 10:44 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
发表于 2008-01-30 10:46 |显示全部楼层
$ cat .vimrc
set tabstop=8
set softtabstop=4
set expandtab
set shiftwidth=4

论坛徽章:
0
发表于 2008-02-04 12:34 |显示全部楼层
用vim

问一下楼上,如果只想.py的文件set那些条件,其余的文件不set怎么写.vimrc?

试了下:

if has(".py")
    set tabstop=8
    ....
endif

不行,tab还是tab..

thanks~

论坛徽章:
0
发表于 2008-02-04 17:35 |显示全部楼层
基本上无论用什么语言,全部用空格。这样比较统一。
缩进,纯C的用两空格,其它所有的都用4空格。
文件格式,只要涉及到多平台,统一使用unix文件格式。
除了要写makefile以外。

论坛徽章:
0
发表于 2008-02-13 16:31 |显示全部楼层
我用tab,没别的,只为了方便,每次敲4空格好麻烦。如果真的需要用其他的编辑器,只需要转化一下就好了。

论坛徽章:
0
发表于 2008-02-14 08:05 |显示全部楼层
原帖由 newfolder 于 2008-2-4 12:34 发表
用vim

问一下楼上,如果只想.py的文件set那些条件,其余的文件不set怎么写.vimrc?

试了下:

if has(".py")
    set tabstop=8
    ....
endif

不行,tab还是tab..

thanks~


从vim的手册里面看来的
在目录~/.vim/ftplugin/里面放一个文件 python.vim , 里面写上 set softstop 这些内容就可以了。
试了下可以,副作用未知。

以下是手册原文:
2. Create the file "~/.vim/ftplugin/c.vim", with the contents:

        setlocal softtabstop=4
        noremap <buffer> <LocalLeader>c o/**************<CR><CR>/<Esc>

Try editing a C file.  You should notice that the 'softtabstop' option is set
to 4.  But when you edit another file it's reset to the default zero.  That is
because the ":setlocal" command was used.  This sets the 'softtabstop' option
only locally to the buffer.  As soon as you edit another buffer, it will be
set to the value set for that buffer.  For a new buffer it will get the
default value or the value from the last ":set" command.

Likewise, the mapping for "\c" will disappear when editing another buffer.
The ":map <buffer>" command creates a mapping that is local to the current
buffer.  This works with any mapping command: ":map!", ":vmap", etc.  The
|<LocalLeader>| in the mapping is replaced with the value of "maplocalleader".

You can find examples for filetype plugins in this directory:

        $VIMRUNTIME/ftplugin/

More details about writing a filetype plugin can be found here:
|write-plugin|.

论坛徽章:
0
发表于 2008-02-15 22:00 |显示全部楼层
原帖由 mcsrainbow 于 2008-2-13 16:31 发表
我用tab,没别的,只为了方便,每次敲4空格好麻烦。如果真的需要用其他的编辑器,只需要转化一下就好了。


你用的什么编辑器?连tab/空格自动互转的功能都没有?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP