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,一经查实,立即删除!

相关文章

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

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

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

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

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

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

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

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

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

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

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

卷积核_漫画:卷积神经网络中的卷积核到底是什么?

卷积计算的直观体现如上所示,一张汽车图片经过了多次卷积操作,一开始卷积在提取低层次的特征(检测边缘),然后逐渐提取高层次的特征(完整的物体)不同的卷积探测器我们可以看到同一张图片经过不同的卷积核,得到的结果是不一样的&…

如何打开win7禁用的无线网卡服务器,Windows7如何使用批处理开启/禁用无线网卡...

对于无线网卡,Win7笔记本用户应该都不会陌生,许多笔记本用户都是在自己的电脑上安装了无线网卡之后,使用无线网络进行联网的,不过对于一些有线用户来说,无线网卡就显得并不太重要了。因此,今天小编就教大家…

超声声场模拟_超声全聚焦(TFM)简介

应读者要求,小编将介绍一下全聚焦TFM的基础知识。如有讲解不对的,欢迎批评指正。全聚焦是超声检测里面的新事物。早在2005前, Caroline Holmes、Paul D. Wilcox等国外学者就开始研究了全聚焦成像,并通过实验得出了TFM相对于常规相…

post修改服务器数据源,postgresql安装及配置超详细教程

1. 安装根据业务需求选择版本,官网下载初始化数据库执行完初始化任务之后,postgresql 会自动创建和生成两个用户和一个数据库:linux 系统用户 postgres:管理数据库的系统用户;密码由于是默认生成的,需要在系…

小程序分享到朋友圈_如何给小程序添加分享朋友圈

微信公众号更新以后,推送不是按照优先来的,你们可以把我的微信公众号点击设置为星标,以便于及时的接收信息.从微信小程序官方分享朋友圈有那么几天了,今天就分享下如何给自己的小程序添加分享朋友圈代码,几行代码的事。根据官方的提示需要基础…

JS代码大全

一、验证类 1、数字验证内 1.1 整数 /^(-|\)?\d$/.test(str) 1.2 大于0的整数 (用于传来的ID的验证) /^\d$/.test(str) 1.3 负整数的验证 /^-\d$/.test(str) 2、时间类 2.1 短时间,形如 (13:04:06) function isTime(str) …

eclipse中查看mysql_eclipse中怎样查看sqlite数据库的表

string createtable(classclazz , string tablename){//实例化一个容器,用来拼接sql语句stringbuffer sbuffer new stringbuffer();//sql语句,第一个字段为_id 主键自增,这是通用的,所以直接写死sbuffer.append("create tab…

敏捷开发之Scrum扫盲篇

现在敏捷开发是越来越火了,人人都在谈敏捷,人人都在学习Scrum和XP... 为了不落后他人,于是我也开始学习Scrum,今天主要是对我最近阅读的相关资料,根据自己的理解,用自己的话来讲述Scrum中的各个环节&#x…

macos xampp mysql 命令_MAC系统XAMPP 中 MySQL命令行client配置使用

在PHP的学习过程中。MySQL预计是必定会接触的。MySQL的管理相信大家也会使用phpmyadmin:好吧。phpmyadmin的确是MySQL管理的神器,你想要的。他好多都有,在开发的过程中。对于后台数据库的设计架构帮助真的非常大。可是。在这篇文章的主角确不…

]Kinect for Windows SDK开发入门(六):骨骼追踪基础 上

原文来自:http://www.cnblogs.com/yangecnu/archive/2012/04/06/KinectSDK_Skeleton_Tracking_Part1.html Kinect产生的景深数据作用有限,要利用Kinect创建真正意义上交互,有趣和难忘的应用,还需要除了深度数据之外的其他数据。这…

Daily Scrum 10.29

时间越来越紧迫,不过大家逐渐进入了状态。虽然在有些问题上大家意见有些不同,但是最终还都是为着团队着想,很好地达成一致了。 MemberToday’s Task Tomorrow’s Task李孟 task615 测试(活动) task571 完成daily scrum 10.29撰文 task615 测试…