vi

Linux——vi命令详解

左心房为你撑大大i 提交于 2019-11-28 13:52:06
Linux vi/vim 所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在。 但是目前我们使用比较多的是 vim 编辑器。 vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正确性,方便程序设计。 相关文章: 史上最全Vim快捷键键位图 — 入门到进阶 什么是 vim? Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。 简单的来说, vi 是老式的字处理器,不过功能已经很齐全了,但是还是有可以进步的地方。 vim 则可以说是程序开发者的一项很好用的工具。 连 vim 的官方网站 ( http://www.vim.org ) 自己也说 vim 是一个程序开发工具而不是文字处理软件。 vim 键盘图: vi/vim 的使用 基本上 vi/vim 共分为三种模式,分别是 命令模式(Command mode) , 输入模式(Insert mode) 和 底线命令模式(Last line mode) 。 这三种模式的作用分别是: 命令模式: 用户刚刚启动 vi/vim,便进入了命令模式。 此状态下敲击键盘动作会被Vim识别为命令,而非输入字符。比如我们此时按下i,并不会输入一个字符,i被当作了一个命令。 以下是常用的几个命令: i 切换到输入模式,以输入字符。 x

Duplicate a whole line in Vim

馋奶兔 提交于 2019-11-28 13:06:38
问题 How do I duplicate a whole line in Vim in a similar way to Ctrl + D in IntelliJ IDEA/Resharper or Ctrl + Alt + ↑ / ↓ in Eclipse? 回答1: y y or Y to copy the line (mnemonic: y ank) or d d to d elete the line (Vim copies what you deleted into a clipboard-like "register", like a cut operation) then p to p aste the copied or deleted text after the current line or P to p aste the copied or deleted text before the current line 回答2: Normal mode: see other answers. The Ex way: :t. will duplicate the

vim toggling buffer overwrite behavior when deleting

隐身守侯 提交于 2019-11-28 12:38:50
Vim is great, but like many people I get really annoyed when I want to copy, delete, then paste -- the yank buffer gets overwritten by the delete action. Now I know there are 101 work-arounds and mappings, some of which are enumerated in posts like this one: Any way to delete in vim without overwriting your last yank? But all of these solutions have drawbacks -- even I were a buffer-guru (which I'm not). For instance, excess keystrokes -- whereas I normally xxxx to quickly delete 4 characters (just one keystroke cuz I hold it down and wait for autorepeat), it is not practical for me to now

VIM命令模式与输入模式切换

本秂侑毒 提交于 2019-11-28 11:13:29
vi编辑器 vi是UNIX和类UNIX环境下的可用于创建文件的屏幕编辑器。vi有两种工作模式:命令模式和文本输入模式。启动vi需要输入vi,按[Spacebar]键并输入文件名后回车。 切换模式键 vi从命令模式切换到文本输入模式。每个键以不同方式使vi进入文本输入模式。按 [ESC] 键使vi从文本输入模式回到命令模式。 表1列出了vi从命令模式切换到文本输入模式的命令键及其功能。 表1 切换到文本输入模式的命令键 键 功能 i 在光标左侧输入正文 I 在光标所在行的行首输入正文 a 在光标右侧输入正文 A 在光标所在行的行尾输入正文 o 在光标所在行的下一行增添新行,光标位于新行的行首 O 在光标所在行的上一行增添新行,光标位于新行的行首 说明: 1. 光标的位置由双下划线(═)标明。 2. 当前行指光标所在的那一行。 退出命令 只有一种方式进入vi,但是有几种方式退出vi,退出方式的选择取决于如何处理编辑后的文件。 除了ZZ命令外,这些命令都以:开始,用[Return]结束命令行。表2列出了vi编辑器的退出命令及其功能。 表2 vi编辑器的退出命令 键 功能 :wq 保存文件,退出vi编辑器 :w 保存文件,但不退出vi编辑器 :q 退出vi编辑器 :q! 不保存文件,退出vi编辑器 ZZ 保存文件,退出vi编辑器 文本修改键 这些键只适用于命令模式

vim编辑器详解

落花浮王杯 提交于 2019-11-28 10:12:29
vi编辑器 作用:编辑文本文件中的内容的工具 命令历史 末行模式中,以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令。 启动vim 在命令行窗口中输入以下命令即可 vim 直接启动vim vim filename 打开vim并创建名为filename的文 vim的模式 vi的工作模式 命令模式:仅仅可以查看内容,但是不能进行修改(默认) 输入模式:可以对文件中的内容进行修改 末行模式:此模式可以执行一些命令 vi打开文件 vi打开文件 vi 文件名 注意: 1. vi打开文件,如果发现文件是空的,那么说明你所打开的文件是不存在的 2. 也就是vi既可以打开现有的文件,也可以创建新文件,只是所创建的新文件内容是空白的 3. vi有增强版本,称之为vim(建议用vim) 4. vi是用来编辑文本文件的,不能用来打开目录 情况1:从命令模式到输入模式 i:在光标所在位置的前插入内容 I:将光标移到到行首,然后进入输入模式 a:将光标向后移到一位,然后进行插入模式(输入的内容会在光标原始位置的后一位。 A:在当前行尾插入 o:在光标所在行的下面新开一行,然后进入输入模式 O:在光标所在行的开面新开一行,然后进入输入模式 命令模式下的常用操作 第一类操作:复制、移动删除文件内容 yy:复制光标所在的行 nyy:复制光标所在的行开始向下的N行 dd

How to copy/paste text from vi to different applications

拜拜、爱过 提交于 2019-11-28 10:03:46
问题 Is it possible to copy/paste text without using :vs? If I have two vi windows open, I can copy/paste text with a mouse. How can I do it with a keyboard? I found two existing questions that are similar to this, but neither one answers my question. how to copy codes in vi to clipboard Copy and paste content from one file to another file in VI 回答1: You can copy/paste by using the + register (read more: Accessing the system clipboard) "+gyy will yank a line, and put it into the + register. You

【正确使用vim编辑器的姿势】

*爱你&永不变心* 提交于 2019-11-28 09:43:07
原文: http://blog.gqylpy.com/gqy/312 vi:可视化接口 (Visual Interface) vim:是vi的增强版 (vi iMprove) vi 编辑器是所有Unix及Linux系统下标准的编辑器,他就相当于windows系统中的记事本一样,它的强大不逊色于任何最新的文本编辑器。它是我们使用Linux系统不能缺少的工具。Unix及linux系统的任何版本下的vi编辑器是完全相同的,学会它后,您将在Linux的世界里畅行无阻。 vim 可以说的vi的升级版本,它可以用多种颜色的方式来显示一些特殊的信息。 vim 具有程序编辑能力,可以以字体颜色辨别语法的正确性,方便程序设计。 vim 会依据文件扩展名或者是文件内的开头消息,来判断该文件的内容而自动的执行该程序的语法判断式,再以颜色来区分显示代码与注册信息。 vim 加入了很多额外的功能,例如支持正则表达式的搜索、多文件编辑、快复制等等。这帮助我们在进行一些配置文件的修改工作时提高了不少的效率。 vim 有三种工作模式,如下图: vim编辑器的配置文件:全局 /etc/vimrc 用户 ~/.vimrc 修改配置文件可使某项配置默认生效,比如在配置文件内加入一行: set nu ,那么打开文件后将默认显示行号。 打开文件 vim + file 打开文件并定位到最后一行 . vim +n file

How can I launch VI from within Java under commons-exec?

自闭症网瘾萝莉.ら 提交于 2019-11-28 08:44:13
问题 I would like to be able to launch VI from within my Java program and wait for the user to quit VI before proceeding. Here's the code snippet that I have currently: ... String previewFileName="test.txt"; // the file to edit CommandLine cmdLine = new CommandLine("/usr/bin/vi"); cmdLine.addArgument(previewFileName); cmdLine.addArgument(">/dev/tty"); cmdLine.addArgument("</dev/tty"); Executor executor = new DefaultExecutor(); try { DefaultExecuteResultHandler resultHandler = new

How to write buffer content to stdout?

廉价感情. 提交于 2019-11-28 08:04:41
Is there any chance to write the content of the current vim buffer to stdout? I'd like to use vim to edit content that was passed via stdin - without the need of a temporary file to retrieve the modified content (on Linux/Unix). Is it possible that a plugin/script - that act on quit or save put the buffer content to stdout? I think :w !tee would work perfectly, jabirali Since you use Linux/Unix, you might also be interested in trying out moreutils . It provides a command called vipe , which reads from stdin , lets you edit the text in $EDITOR , and then prints the modified text to stdout . So

Is it possible to use VI or VIM keymap in NetBeans?

余生长醉 提交于 2019-11-28 06:53:36
Vim is my favorite tool for programming in OSX, but my team mate all use NetBeans. Some of them use Eclipse Keymap. Any suggestion plug-in to enable VI command in NetBeans 6.5? Related: Does any IDE have a vi keybindings option? Check jVi , a Vi emulator for NetBeans. I've also found ViEx , the project seems to be pretty active... jVi can be installed using the NetBeans plugin manager; from NB do Menu>Tools>Plugins Select the tab "Available Plugins", in search enter "jvi". First install "jVi for NB-xx Update Center", then you can install jVi. 来源: https://stackoverflow.com/questions/483962/is