Buffers, windows, and tabs

If you’ve moved to Vim from an editor like Notepad++ or TextMate, you’ll be used to working with the idea of tabs in a text editor in a certain way. Specifically, a tab represents an open file; while the tab’s there, you’ve got an open file, as soon as you close it, it goes away. This one-to-one correspondence is pretty straightforward and is analogous to using tabs in a web browser; while the page is open, there’s a tab there, and you have one page per tab, and one tab per page.

Vim has a system for tabs as well, but it works in a completely different way from how text editors and browsers do. Beginners with Vim are often frustrated by this because the model for tabs is used so consistently in pretty much every other program they’re accustomed to, and they might end up spending a lot of fruitless time trying to force Vim to follow the same model through its configuration.

I think a good way to understand the differences in concept and usage between Vim’s three levels of view abstraction — bufferswindows, and tabs – is to learn how to use each from the ground up. So let’s start with buffers.

Buffers

buffer in Vim is probably best thought of for most users as an open instance of a file, that may not necessarily be visible on the current screen. There’s probably a more accurate technical definition as a buffer need not actually correspond to a file on your disk, but it’ll work for our purposes.

When you open a single file in Vim, that file gets put into a buffer, and it’s the only buffer there on startup. If this buffer is unmodified (or if you’re using hidden), and you open another file with :edit, that buffer goes into the background and you start working with the new file. The previous buffer only goes away when you explicitly delete it with a call to :quit or :bdelete, and even then it’s still recoverable unless you do :bwipe.

By default, a buffer can only be in the background like this if it’s unmodified. You can remove this restriction if you like with the :set hidden option.

You can get a quick list of the buffers open in a Vim session with :ls. This all means that when most people think of tabs in more familiar text editors, the idea of a buffer in Vim is actually closest to what they’re thinking.

Windows

window in Vim is a viewport onto a single buffer. When you open a new window with :split or:vsplit, you can include a filename in the call. This opens the file in a new buffer, and then opens a new window as a view onto it. A buffer can be viewed in multiple windows within a single Vim session; you could have a hundred windows editing the same buffer if you wanted to.

Windows in Vim

Vim Session with multiple windows open, both horizontally and vertically.

Tabs

Finally, a tab in Vim is a collection of one or more windows. The best way to think of tabs, therefore, is as enabling you to group windows usefully. For example, if you were working on code for both a client program and a server program, you could have the files for the client program open in the first tab, perhaps in three or four windows, and the files for the server program open in another, which could be, say, seven windows. You can then flick back and forth between the tabs using :tabn and:tabp.

Tab usage in Vim

Two tabs open in Vim, each with multiple windows. Move between two tabs with :tabn and :tabp.

This model of buffers, windows, and tabs is quite a bit more intricate than in other editors, and the terms are sometimes confusing. However, if you know a bit about how they’re supposed to work, you get a great deal more control over the layout of your editing sessions as a result. Personally, I find I rarely need tabs as with a monitor of sufficient size it suffices to keep two or three windows open at a time when working on sets of files, but on the odd occasion I do need tabs, I do find them tremendously useful.

Thanks to Hacker News users anonymous and m0shen for pointing out potential confusion with the :set hidden option and the :bdelete command.

转载于:https://www.cnblogs.com/threef/p/3355369.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/433077.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

js如何获取计算机当前时间,js获取当前系统时间

搜索热词下面是编程之家 jb51.cc 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。var myDate new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份(4位,1970-????)myDate.getMonth(); //获取…

docker访问宿主机mysql_docker容器内访问宿主机127.0.0.1服务

点击上方”技术生活“,选择“设为星标”做积极的人,而不是积极废人背景原因分析解决方案背景已经通过docker启动的elasticsearch 服务,监听端口9200。在宿主机中直接通过http://127.0.0.1:9200 可以直接访问,但是通过docker访问缺…

ADO.NET+Access: 3,参数 @departmentName 没有默认值

ylbtech-Error-ADO.NETAccess: 3,参数 departmentName 没有默认值。1.A,错误代码返回顶部 3,参数 departmentName 没有默认值。1.B,出错原因分析返回顶部未解决1.C,相关解决方法返回顶部作者:ylbtech出处:http://ylbtech.cnblogs.com/本文版权归作者和博…

lombok有参构造注解_Java高效开发工具: Lombok

Lombok, 一个Java开发必备效率工具,可以大大避免编写一些常用方法(get/set, hashcode等),简化开发。虽然现在IDE很多都可以通过快捷键生成POJO的一些方法了,但是如果该POJO字段发生变动后,还是需要程序员再次手动重新生成相关方法…

JavaScript操作大全整理(思维导图三--函数基础)

3.JavaScript函数基础 转载于:https://www.cnblogs.com/yuxia/p/3360806.html

__attribute__ 之weak,alias属性

Weak Alias 跟 Weak Reference 完全没有任何关系,不过是我在看到 Weak Reference 的时候想到的而已。 Weak Alias 是 gcc 扩展里的东西,实际上是函数的属性。这个东西在库的实现里面可能会经常用到,比如 glibc 里面就用了不少。抄录一段 gcc …

nginx指定配置文件启动_NGINX安全加固手册

NIGNX系统安全基线规范1.概述1.1 适用范围本配置标准的使用者包括:各事业部服务器负责人。 各事业部服务器负责人按规范要求进行认证、日志、协议、补丁升级、文件系统管理等方面的安全配置要求。对系统的安全配置审计、加固操作起到指导性作用。1.2 文档内容本文档…

口袋网咖已有服务器在使用怎么注销,口袋网咖_口袋网咖常见问题_口袋网咖专区...

口袋网咖是专门为游戏高玩打造的手机变电脑软件,虚拟电脑神器,体验各种电脑游戏,非常的方便,能让小伙伴尽情的体验手机电脑的感觉,很多小伙伴在使用过程中遇到了一些问题,快啦网为大家分享口袋网咖常见问题…

p

都不知道简历去投什么地方。游戏都卖不出去,又做不出口碑好的。这些人是心存侥幸还是心存坚持。 感觉自己搞不清楚就很难再出发。转载于:https://www.cnblogs.com/YOUEN/p/3364227.html

bbb u-boot 验证 emmc

目标: 参考"common/cmd_mmc.c"的查找emmc的代码,在mmc总线初始化函数后,遍历mmc总线,查找emmc并 打印emmc信息。 在"drivers/mmc/mmc.c"中的mmc_initialize函数的最后面添加我们的遍历函数 int mmc_initia…

统计个人已完成的工作量_团队工作量及团队价值贡献统计、核算、评审及提升的重要性...

在推行阿米巴经营模式时,需要进行企业内部产品及服务全价值分析,也就是企业内部团队产品及服务价值增值的全过程分析,团队价值增值是团队存在的目的和意义,对于团队经营来讲,团队工作量就团队的收入,团队价…

hyper服务器虚拟网卡和实际网卡,Hyper-V 3 虚拟网卡带宽应用限制

Windows Server 2012的Hyper-V 3中,打来了系列新功能,例如网卡流量限制功能。 基础架构注意的问题宿主服务器规划过程中,管理员主要考虑服务器基础架构中的CPU、内存、磁盘空间等必要因素,但是网络适配器(简称网卡)通常属于被忽略…

数据结构--------------静态表的希尔排序

#define LT(a,b) ((a)< (b))#define EQ(a,b) ((a)(b))#define LQ(a,b) ((a)<(b)) typedef struct ElemType{//表中元素结构 int key; char name[20];}ElemType; typedef struct SSTable{//静态表结构 ElemType *elem; int length;}SSTable; ElemType r[20];//全局变量,用…

智能集群理论优化控制_数学学科学术报告九:机器人集群的智能协同控制方法_中国计量大学...

数学学科学术报告九&#xff1a;机器人集群的智能协同控制方法_中国计量大学中国计量大学 免费考研网/2018-05-17报告题目&#xff1a;机器人集群的智能协同控制方法报告人&#xff1a;孙长银(东南大学 教授)报告时间&#xff1a;2018.04.09 15:30-16:30报告地点&#xff1a;格…

css复选框如何调大一些,创建CSS放大复选框

您可以随时使用复选框来勾选自己的复选框.这允许更多的跨浏览器兼容的解决方案.我做了一个快速演示here,显然你必须得到一个透明的.png的滴答,而不是我得到的.input[typecheckBox]:checked ~ div label{background: url(http://ramyasspace.files.wordpress.com/2011/06/tick.j…

outside of class is not definition

有一种可能的情况&#xff1a;You have semicolons (;) at the end of all your function definitions making the compiler think theyre declarations. 即在方法定义的后面都误添加上了";",导致编译器认为这仅仅是个声明。

Makefile中=、:=、+=、?=的区别

&#xff0c;就是基本的赋值 :&#xff0c;覆盖原来的值 &#xff0c;添加新值 ?&#xff0c;如果没有赋值则赋值转载于:https://www.cnblogs.com/wangluojisuan/p/3369072.html

用python画面积图_Python笔记:用matplotlib绘制面积图

用pyecharts绘制出来的面积图、圆环图太有个性了&#xff0c;未免感觉有点“高处不胜寒”。今晚虽然休息&#xff0c;但继用matplotlib绘制折线图之后&#xff0c;我又心血来潮地想用matplotlib来制作一点面积图&#xff0c;因为这在零售行业也是常用的可视化图形之一。具体如下…

状态机思路在程序设计中的应用

状态机思路在单片机程序设计中的应用 状态机的概念 状态机是软件编程中的一个重要概念。比这个概念更重要的是对它的灵活应用。在一个思路清晰而且高效的程序中&#xff0c;必然有状态机的身影浮现。 比如说一个按键命令解析程序&#xff0c;就可以被看做状态机&#xff1a;本来…

css 实现标签切换,CSS_纯CSS实现Tab切换标签效果代码,本文实例讲述了纯CSS实现Tab切 - phpStudy...

纯CSS实现Tab切换标签效果代码本文实例讲述了纯CSS实现Tab切换标签效果代码。分享给大家供大家参考。具体如下&#xff1a;这是一款纯CSS实现的Tab简洁版&#xff0c;很不错的效果&#xff0c;希望大家喜欢。运行效果截图如下&#xff1a;在线演示地址如下&#xff1a;http://d…