vi

vim文本编辑器基本命令

半城伤御伤魂 提交于 2019-11-27 15:14:16
今天给大家介绍vim文本编辑器中的一些基本命令和命令实例。 · 本章介绍 1、 基本概念 2、 三种模式基本操作 ------------概念简介----------- Vim是一个类似于Vi的著名的功能强大、高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性。VIM是自由软件。Vim普遍被推崇为类Vi编辑器中最好的一个,事实上真正的劲敌来自Emacs的不同变体。 文本编辑器的作用 创建和修改文本文件 维护Linux系统中的各种配置文件 Linux中最常用的文本编辑器 vi:类UNIX操作系统的默认文本编辑器 vim:vim是vi文本编辑器的增强版 vi编辑器的三种工作模式 命令模式:默认模式,移动光标,剪切/粘贴文本(界面表现:左下角显示文件名或为空) 输入模式:修改文本(界面表现:左下角显示—INSERT–)插入模式下,按ESC按键返回 末行模式:保存、退出等(界面表现:左下角显示—VISUAL–)末行模式下连续按两次ESC按键返回末行模式 · 不同模式之间的切换 命令模式的基本操作——光标移动 操作类型 操作键 功能 方向 上、下、左、右 翻页 Page Down或者Ctrl+F 向上翻动一整页内容 Page Up或Ctrl+B 向上翻动一整页内容 行内快速跳转 Home键或者“^”、数字“0” 跳转至行首 End或者"$"键 跳转至行尾 行间快速跳转 1G或者gg

How do I make vi editing-mode work in IRB when using RVM?

丶灬走出姿态 提交于 2019-11-27 14:56:13
问题 I " set editing-mode vi " in my .inputrc on my Mac OS system, which allows vi editing in IRB. When I'm using a RVM Ruby, the IRB sessions don't process this directive. Does anyone know a solution? 回答1: Have you got set -o vi set, either at the command-line or in one of your startup scripts? That turns it on for the shell. I have both " set editing-mode vi " and set -o vi and have Vi-like editing in IRB. EDIT: Try creating ~/.editrc , put bind -v in it. Snow Leopard has support for editline

Getting Vim to recognize XML

▼魔方 西西 提交于 2019-11-27 13:51:43
问题 I would like Vim to help me indent my XML files like my C code. However, when I use gg=G It just sets everything to the left. Do I need to designate a syntax? Is XML recognized as a language? 回答1: Put filetype plugin indent on in your .vimrc to have Vim automatically identify .xml files as xml. You might need to put set nocompatible before that. If the file extension is not .xml, you can make Vim threat it like xml by using :set filetype=xml After you do that, Vim's autoindention (and syntax

Limiting search scope for code in Vim

北城以北 提交于 2019-11-27 13:12:39
问题 How can I limit the search scope in Vim to the function/class/code block that the cursor is currently in, without having to figure out what the line numbers are? Being able to search in the visual selection would also do, as there are methods for selecting the current code block. (Similar to this question, but more generic) 回答1: I'm going to just copy and paste the entire content of "Searching with / and ?" (within a visual selection) from the Vim Tips Wiki. In visual mode, / and ? will

is it possible to mapping Alt-hjkl in Insert mode?

早过忘川 提交于 2019-11-27 13:11:35
问题 before describing my problem, I'd list the env. applications here: OS:linux 2.6.37-ARCH (archlinux i686) vim: 7.2.436 Terminal emulator: urxvt (with 256colors patch) kent$ echo $TERM rxvt-256color screen: Screen version 4.00.03 (FAU) 23-Oct-06 I run vim in terminal. I want to move cursor in INSERT mode by pressing ALT-hjkl, after the cursor moved, stay in INSERT mode, so that I could continue typing words. articles I found: http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim http:

Ubuntu学习笔记一 基本环境的搭建

这一生的挚爱 提交于 2019-11-27 12:59:48
本帖来源于网络各位大侠的总结,然后经过俺自己的测试,由于参考文档太多,所以就没有引用了,请见谅! 1.XP中硬盘安装ubuntu A. 首先下载Grub4Dos和ubuntu的光盘, 解压grldr 和 menu.lst 两个文件至XP的C盘根目录下, 然后修改menu.lst在末尾添加如下内容: 其中vmlinuz和initrd.lz从光盘中解压出来 这些通通放到C盘 title Install Ubuntu root (hd0,0) kernel (hd0,0)/vmlinuz boot=casper iso-scan/filename=/Ubuntu.iso ro quiet splash locale=zh_CN.UTF-8 initrd (hd0,0)/initrd.lz B. 修改Windows XP的boot.ini文件 在命令提示符下去掉boot.ini的相关属性: attrib -s -h -r c:\boot.ini 然后编辑boot.ini在末尾添加: C:\grldr="install Ubuntu 10.10" C. 进入ubuntu之后,请卸载光盘 sudo umount -l /isodevice D. 点击桌面安装图标安装到硬盘 2. vi 问题解决方法 使用vi命令时,不能正常编辑文件,使用方向键时老是出现很多字母 A.执行命令 sudo apt

Ubuntu vi 方向键出现字母问题解决方法

别说谁变了你拦得住时间么 提交于 2019-11-27 12:59:36
使用vi命令时,不能正常编辑文件,使用方向键时老是出现很多字母 在网上找了个方法 问题已经解决 分享一下: 只要依次执行以下两个命令即可完美解决Ubuntu下vi编辑器方向键变字母的问题。 一.执行命令 sudo apt-get remove vim-common 二.执行命令 sudo apt-get install vim 再试试Vi编辑器,是不是恢复正常了。 来源: oschina 链接: https://my.oschina.net/u/438493/blog/86345

Vim “show my last command” command?

◇◆丶佛笑我妖孽 提交于 2019-11-27 09:57:03
问题 Is there a command which shows what was the last command in normal mode? Suppose I accidently hit random key and got some unexpected result. Sure I can undo it, but could I reveal what key was pressed and how it was interpreted? 回答1: Hit the colon ( : ) and then use the up arrow to start going back through previous commands. You can use the up/down arrows too to move around the list. 回答2: q: will show you command history in Vim. q/ will show you history of searches 回答3: The text from the last

Vim delete blank lines

梦想的初衷 提交于 2019-11-27 09:55:34
What command can I run to remove blank lines in Vim? :g/^$/d :g will execute a command on lines which match a regex. The regex is 'blank line' and the command is :d (delete) nearly_lunchtime Found it, it's: g/^\s*$/d Source: Power of g at vim wikia Brief explanation of :g :[range]g/pattern/cmd This acts on the specified [range] (default whole file), by executing the Ex command cmd for each line matching pattern (an Ex command is one starting with a colon such as :d for delete). Before executing cmd , " . " is set to the current line. :v/./d or :g/^$/d or :%!cat -s The following can be used to

Traversing text in Insert mode

蹲街弑〆低调 提交于 2019-11-27 09:55:24
While in Insert Mode in Vim, is there any way to traverse the text moving some characters forward and backward other than using the arrow keys? If I press h , j , k and l while in Insert mode, the actual characters are printed on screen instead of moving through the text. The way I'm doing it at the moment is having to resort to Ctrl + [ ( Esc ) and traversing the text then; but obviously that is not productive. P Shved You seem to misuse vim, but that's likely due to not being very familiar with it. The right way is to press Esc , go where you want to do a small correction, fix it, go back