vi

Vim 迎来 25 周年纪念日

蹲街弑〆低调 提交于 2019-11-30 05:08:53
Bram Moolenaar曾经是 Unix 上的 vi 用户,但 Amiga 上却没有与其类似的编辑器。在三年的开发之后,1991 年 11 月 2 日,他发布了“仿 vi 编辑器Vi IMitation”(也就是 Vim)的第一个版本。 两年之后,随着 2.0 版本的发布,Vim 的功能集已经超过了 vi,所以这款编辑器的全称也被改为了“vi 增强版Vi IMproved”。现在,刚刚度过 25 岁生日的 Vim,已经可以在绝大部分平台上运行——Windows、OS/2、OpenVMS、BSD、Android、iOS——并且已在 OS X 及很多 Linux 发行版上成为标配软件。它受到了许多赞誉,也受到了许多批评,不同组织或开发者也会围绕它来发起争论,甚至有些面试官会问:“你用 Emacs 还是 Vim?”Vim 已拥有自由许可证,它基于慈善软件证书charityware license(“帮助乌干达的可怜儿童”)发布,该证书与 GPL 兼容。 Vim 是一个灵活的、可扩展的编辑器,带有一个强大的插件系统,被深入集成到许多开发工具,并且可以编辑上百种编程语言或文件类型的文件。 在 Vim 诞生二十五年后,Bram Moolenaar 仍然在主导开发并维护它——这真是一个壮举!Vim 曾经在超过 20 年的时间里数次间歇中断开发,但在 2016 年 9 月,它发布了 8.0

Conditional replace in vim

喜欢而已 提交于 2019-11-30 04:47:48
问题 I'd like do use vim search-and-replace to replace all " with ' and vice-versa. Is there a way to achieve this in one step? I'm thinking of something like this: :s/\("\|'\)/\1=="?':"/ Where of course the \1=="?':" -part is something that works in vim. Thanks in advance! 回答1: That's a case for :help sub-replace-special : :s/["']/\=submatch(0) == '"' ? "'" : '"'/g This matches any of the two quotes (in a simpler way with [...] ), and then uses the ternary operator to turn each quote into its

How can I open vim with a particular line number at the top?

末鹿安然 提交于 2019-11-30 04:40:59
I know it is possible to have vim open a file at particular line number using this syntax: vim +500 filename However, I would like it to open with the specified line at the top of the editor window, not in the middle. You could issue zt after opening the file, so something like: vim +500 filename -c 'normal zt' . As an alternative (because I ended up here searching for it), if you want to have the syntax vim <filename>:<linenumber> , eg vim test.rb:45 , you can use vim-fetch with Vundle : Plugin 'kopischke/vim-fetch' This should do it: vim +'500|norm! zt' filename Or you could just start the

How to find the callers and callee of a function in C code in vi/vim?

≯℡__Kan透↙ 提交于 2019-11-30 04:13:57
I want to know how can I easily click (or maybe use some easy shortcuts) on a function name and find all its callee or open where it has been defined. Most of the web manuals in web are really hard to follow or don't happen to work out. Say I want to click on allocuvm and see where it has been defined? uint newstk=allocuvm(pgdir, USERTOP-PGSIZE, USERTOP); For that, Vim integrates with the cscope tool; see :help cscope for more information. Ciro Santilli 新疆改造中心996ICU六四事件 cscope minimal example Ingo mentioned it, here is an example. Go to the base directory of your project and run: cscope -Rb

Vim

∥☆過路亽.° 提交于 2019-11-30 02:28:16
什么是 vim? 所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在。 但是目前我们使用比较多的是 vim 编辑器。 vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正确性,方便程序设计。 Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。 简单的来说, vi 是老式的字处理器,不过功能已经很齐全了,但是还是有可以进步的地方。 vim 则可以说是程序开发者的一项很好用的工具。 vi/vim 的使用 基本上 vi/vim 共分为三种模式,分别是 命令模式(Command mode) , 输入模式(Insert mode) 和 底线命令模式(Last line mode) 。 这三种模式的作用分别是: 命令模式: 用户刚刚启动 vi/vim,便进入了命令模式。 此状态下敲击键盘动作会被Vim识别为命令,而非输入字符。比如我们此时按下i,并不会输入一个字符,i被当作了一个命令 移动光标 w(e)  移动光标到下一个单词b    移动到光标上一个单词数字0  移动到本行开头$    移动光标到本行结尾H    移动光标到屏幕首行M    移动到光标到屏幕的中间一行L    移动光标到屏幕的尾行gg    移动光标到文档的首行G    移动光标到文档尾行ctrl + f 

Linux基础命令(编辑)

那年仲夏 提交于 2019-11-30 01:21:13
目录 Linux基础命令(编辑) 文件层级系统 重定向 Linux下的编辑器介绍 vi/vim的特点 vi/vim的三种编辑模式 vi/vim的三种编辑模式间转换的方式 打开文件方式 关闭文件方式 关闭文件方式 字符编辑 删除命令:d 复制与粘贴 替换、撤销编辑与重复编辑操作 Linux基础命令(编辑) 文件层级系统 FHS:文件层级系统 /:根分区 /boot:系统启动相关的文件,如内核(vmlinuz)、initrd(initramfs)以及grub(bootloader) /dev:设备文件,不能单独分区 /etc:配置文件目录 /home:普通用户家目录 /root:管理员家目录 /lib:库文件目录 /media:挂载点目录,通常用来挂载移动设备 /mnt:挂载点目录,通常用来挂载额外的临时文件系统,比如另一块硬盘 /opt:可选目录,早期通过用来安装第三方软件 /proc:伪文件系统,内核映射文件,不能单独分区 /sys:伪文件系统,跟硬件设备相关的属性映射文件,不能单独分区 /tmp:临时文件目录 /var:可变化的文件,比如log、cache。存放日志文件、pid文件、lock文件 /bin:可执行文件,用户命令 /sbin:管理命令 /usr:全局共享只读文件。提供操作系统核心功能,可以单独分区    /usr/bin    /usr/sbin    /usr

Why do gedit and vim hide the final newline from the user?

徘徊边缘 提交于 2019-11-30 01:18:16
问题 Let's assume we have two text documents: Our first file contains " hi " as text. Our second file contains " hi " as text. When we open these two files in gedit, vi, or vim, the two files are visually identical in every way. However, when we run xxd on the files, we get the following: Hex content of our first file reads: 6869 Hex content of our second file reads: 6869 0a Aha! There's an invisible newline. In vim, if we were paying close enough attention to the status bar and happen to

Does any IDE have a vi keybindings options? [closed]

梦想与她 提交于 2019-11-29 23:00:15
One of the reasons I usually don't use an IDE for development is that I'm so used to vi keybindings that I usually end up messing up my text and putting in lots of ":w"s, and I can't use vi's powerful regex replace mechanism. Are there any IDEs that allow you to configure vi keybindings or use vi as the editor within the IDE? Related: Is it possible to use vi or vim keymap in NetBeans? There's jVi for NetBeans. There's also viPlugin for Eclipse, but it's not free. :( There is ViEmu which provides vim key bindings for Visual Studio. I haven't used it, but I probably would if I were working in

Why the dot (.) command is so useful in VIM?

二次信任 提交于 2019-11-29 20:45:38
I use VIM pretty regularly now but I never use the dot (.) command to repeat the previous action. I keep reading about how awesome it is but I never see any real world examples that make sense to me and the way I code in VIM. What are some real world examples that show how awesome the dot (.) command is? Benoit Here are some actions that I do with the dot command: Simpler than :%s/\<word\>/replacement/gc is * on the word, then cereplacement<esc> and then repeat n. . This is nice if you have two or three occurrences of your word. If you have several words that you want to replace, then go to