Put your desired settings in the ~/.vimrc file -- See below for some guidelines and best practices.

There are four main ways to use tabs in Vim:

  1. Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4 (or 3 or whatever you prefer) and use 'noexpandtab'. Then Vim will use a mix of tabs and spaces, but typing and will behave like a tab appears every 4 (or 3) characters.

    Note: Setting 'tabstop' to any other value than 8 can make your file appear wrong in many places (e.g., when printing it).

  2. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use 'expandtab'. This way you will always insert spaces. The formatting will never be messed up when 'tabstop' is changed.

  3. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use a |modeline| to set these values when editing the file again. Only works when using Vim to edit the file.

  4. Always set 'tabstop' and 'shiftwidth' to the same value, and 'noexpandtab'. This should then work (for initial indents only) for any tabstop setting that people use. It might be nice to have tabs after the first non-blank inserted as spaces if you do this though. Otherwise aligned comments will be wrong when 'tabstop' ischanged.

set tabstop=4
set shiftwidth=4
set noexpandtab
set smarttab
set softtabstop=4

vi set the tab width for python的更多相关文章

  1. 如何在vi中设置tab的长度

    在使用vi写python时(其实,不管用什么写python程序时,都要注意),首先要将Tab键的长度设为4,因为使用python编程时,我们是通过缩进来实现作用域的,所以要统一Tab键的长度.具体方法 ...

  2. VI/VIM修改Tab为4个空格

    配置方法 在当前用户目录下创建或修改~/.vimrc Root用户下修改/etc/virc 和 /etc/vimrc set ts= set softtabstop= set expandtab se ...

  3. Linux系统下设置vi编辑器,tab键为4

    1.cd ~ 2.vi .exrc 3.set tabstop=4(保存并退出)即可

  4. vi/vim下tab的长度修改

    默认下的长度是8,如果要想修改可以在根目录下新建'.vimrc'文件 里面的内容是: [root@localhost 09:06 ~]# cat .vimrc set tabstop=4 set sh ...

  5. python 添加tab补全

    在平时查看Python方法用到tab补全还是很方便的. 1. mac 平台 配置如下: mac是类Unix平台,需要在添加一条配置内容到bash_profile 中(默认是没有这个文件,可以新建一个放 ...

  6. vi/vim tab键空格数修改

    更改Tap键单位 vi/vim编辑器默认情况下,每按一次Tap相对于8个空格. (1)临时性更改 使用vi打开文件后,输入如下命令: :set tabstop=4 命令释义:更改为相当于四个空格. ( ...

  7. Windows 下python的tab自动补全

    方法一:安装一个ipython就OK啦,而且关键字还能高亮显示呢 一.打开cmd,输入pip3 install ipython联网安装 二.安装成功后,cmd里运行ipython,成功啦. 方法二:写 ...

  8. 巨蟒python全栈开发-第11阶段 ansible_project3

    今日大纲: 1.用户创建 2.前端优化 3.用户编辑 4.用户删除 5.ansible api介绍 1.用户创建 新建一个user_create.html的页面 <form class=&quo ...

  9. 翻译:打造基于Sublime Text 3的全能python开发环境

    原文地址:https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ ...

随机推荐

  1. 【python+selenium自动化】设置Chrome启动参数

    起因:直接用selenium的webdriver启动chrome,会弹出“Chrome正在受到自动软件的控制”,并且窗口较小,是因为chrome没有加载任何配置 解决:点进selenium的Chrom ...

  2. 【MM系列】SAP 通过原材料找到成品的函数

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP 通过原材料找到成品的函数   ...

  3. LeetCode.874-走路机器人模拟(Walking Robot Simulation)

    这是悦乐书的第335次更新,第360篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第205题(顺位题号是874).网格上的机器人从点(0,0)开始并朝北.机器人可以接收三 ...

  4. kafka学习(八)

    管理kafka     主题操作 1.在集群里创建一个主题需要用到3个参数.这些参数是必须提供的,尽管有些已经有broker级别的默认值.   主题名字,想要创建的主题的名字,主题名字可以包含字母,数 ...

  5. (已实践)PLSQL本地还原Oracle数据库dmp文件

    这个方法很烂,导致重装Oracle时候处处出现问题,不建议使用这个方法,除非你以后不再用Oracle这个软件了,这个方法很烂,再评论一下. 第一,启动服务,(如果数据库处于启动状态,那么略过这一步) ...

  6. cdh平台问题

    问题背景:内容的不懂之处,可以私信博主.友好交流使用.主要针对的问题种类有:网络桥接报错.网卡文件问题(该问题主要看你的安装脚本文件里面写的是否和主机对应,也是运行环境的问题).scm表中没有节点信息 ...

  7. spring - 第N篇 一些笔记

    1.properties文件的引入 <bean id="propertyConfigurer" class="org.springframework.beans.f ...

  8. CM使用MySQL数据库预处理scm_prepare_database.sh执行报错:java.sql.SQLException: Access denied for user 'scm'@'hadoop101.com' (using password: YES)

    1.报错提示: [root@hadoop101 ~]# /opt/module/cm/cm-/share/cmf/schema/scm_prepare_database.sh mysql cm -hh ...

  9. C#基础篇之C#和 .Net框架的概念和运行原理

    一.微软平台的发展史 二..Net框架包含的东西 1.名词解释 BCL:基类库(Base Class Library)系统和底层提供的最基本的类库 CLR:公共语言运行时(Common Languag ...

  10. HDU 1864 最大报销额 0-1背包

    HDU 1864 最大报销额 0-1背包 题意 现有一笔经费可以报销一定额度的发票.允许报销的发票类型包括买图书(A类).文具(B类).差旅(C类),要求每张发票的总额不得超过1000元,每张发票上, ...