vim

Differences between Emacs and Vim

耗尽温柔 提交于 2019-12-28 07:12:12
问题 Without getting into a religious argument about why one is better than the other, what are the practical differences between Emacs and Vim? I'm looking to learn one or the other, but I realize the learning curve for each is high and I can't decide. I have never used an editor of this type (I've always used IDEs), so anything that helps a newbie is a plus. Before a flame war starts: I'm not asking which is better, I'm asking the differences between the two. I would like an objective comparison

Differences between Emacs and Vim

馋奶兔 提交于 2019-12-28 07:12:12
问题 Without getting into a religious argument about why one is better than the other, what are the practical differences between Emacs and Vim? I'm looking to learn one or the other, but I realize the learning curve for each is high and I can't decide. I have never used an editor of this type (I've always used IDEs), so anything that helps a newbie is a plus. Before a flame war starts: I'm not asking which is better, I'm asking the differences between the two. I would like an objective comparison

How to move screen without moving cursor in Vim?

陌路散爱 提交于 2019-12-28 07:11:58
问题 I recently discovered Ctrl + E and Ctrl + Y shortcuts for Vim that respectively move the screen up and down with a one line step, without moving the cursor . Do you know any command that leaves the cursor where it is but moves the screen so that the line which has the cursor becomes the first line? (having a command for the last line would be a nice bonus). I can achieve this by manually pressing Ctrl + E (or Ctrl + Y ) the proper number of times, but having a command that somehow does this

Vim positive lookahead regex

不羁的心 提交于 2019-12-28 05:17:27
问题 I am still not so used to the vim regex syntax. I have this code: rename_column :keywords, :textline_two_id_4, :textline_two_id_4 I would like to match the last id with a positive lookahead in VIMs regex syntax. How would you do this? \id@=_\d$ This does not work. This perl syntax works: id(?=_\d$) Edit - the answer: /id\(_\d$\)\@= Can someone explain the syntax? 回答1: If you check the vim help, there is not much to explain: ( :h \@= ) \@= Matches the preceding atom with zero width. {not in Vi

Vim positive lookahead regex

試著忘記壹切 提交于 2019-12-28 05:17:24
问题 I am still not so used to the vim regex syntax. I have this code: rename_column :keywords, :textline_two_id_4, :textline_two_id_4 I would like to match the last id with a positive lookahead in VIMs regex syntax. How would you do this? \id@=_\d$ This does not work. This perl syntax works: id(?=_\d$) Edit - the answer: /id\(_\d$\)\@= Can someone explain the syntax? 回答1: If you check the vim help, there is not much to explain: ( :h \@= ) \@= Matches the preceding atom with zero width. {not in Vi

How can I change a file's encoding with vim?

落爺英雄遲暮 提交于 2019-12-28 03:16:18
问题 I'm used to using vim to modify a file's line endings: $ file file file: ASCII text, with CRLF line terminators $ vim file :set ff=mac :wq $ file file file: ASCII text, with CR line terminators Is it possible to use a similar process to change a file's unicode encoding? I'm trying the following, which doesn't work: $ file file.xml file.xml: Unicode text, UTF-16, little-endian $ vim file :set encoding=utf-8 :wq $ file file.xml file.xml: Unicode text, UTF-16, little-endian I saw someone say

cscope or ctags why choose one over the other? [closed]

南笙酒味 提交于 2019-12-28 03:15:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 months ago . I primarily use vim / gvim as an editor and am looking at using a combination of lxr (the Linux Cross Reference) and either cscope or ctags for exploring the kernel source. However, I haven't ever used either cscope or ctags and would like to hear why one might choose one over the other taking into

Linux中的文本编辑之VIM用法及Linux系统根文件系统的层级目录

╄→гoц情女王★ 提交于 2019-12-28 03:10:00
Linux中的文本编辑之VIM用法及Linux系统根文件系统的层级目录 【1】文本编辑之VIM的用法 1.vim的基本用法概述 1.vim是全球著名的两大文本编辑器之一 2.vim有三种模式:插入模式,命令模式,退出模式。 3.按键i为插入模式,按键esc退出插入模式。 2.vim命令模式下调整工作参数 1.在命令模式下 例如 :set nu 添加行号 注意:在此命令下的设定为临时设定,当退出vim时设定自动消失。 2.vim下永久设定 vim etc/vimrc set参数 3.vim中字符的搜索 1./关键字 #表示高亮显示关键字 2. :noh #撤销高亮 3. n向下匹配,N向上匹配 4.vim中的字符管理 1.复制 yl #复制一个字符 yy #复制一个单词 yw #复制一行 2.删除 dl #删除一个字符 dw #删除一个单词 dd #删除一行 3.剪切 cl #剪掉一个字符 cw #删除一个单词 cc #删除一行 注意:当进入剪切模式会自动进入插入模式 4.p #粘贴 u #撤销 ctrl+r #恢复上一步操作 5.vim可视化模式 在命令行模式下按键ctrl+v,然后移动光标选中区域,如果在可视化模式下批量添加字符,按键大写I,加入字符后,按键esc键后就会批量添加成功。 6.vim中字符的替换 :%s/原字符/替换后的字符/g 7.vim的分屏功能 ctrl +w

VIM 快捷键

孤者浪人 提交于 2019-12-28 03:02:01
关于Vim vim是我最喜欢的编辑器,也是linux下第二强大的编辑器。 虽然emacs是公认的世界第一,我认为使用emacs并没有使用vi进行编辑来得高效。 如果是初学vi,运行一下vimtutor是个聪明的决定。 Vim的几种模式 正常模式:可以使用快捷键命令,或按:输入命令行。 插入模式:可以输入文本,在正常模式下,按i、a、o等都可以进入插入模式。 可视模式:正常模式下按v可以进入可视模式, 在可视模式下,移动光标可以选择文本。按V进入可视行模式, 总是整行整行的选中。ctrl+v进入可视块模式。 替换模式:正常模式下,按R进入。 启动Vim vim -c cmd file: 在打开文件前,先执行指定的命令; vim -r file: 恢复上次异常退出的文件; vim -R file: 以只读的方式打开文件,但可以强制保存; vim -M file: 以只读的方式打开文件,不可以强制保存; vim -y num file: 将编辑窗口的大小设为num行; vim + file: 从文件的末尾开始; vim +num file: 从第num行开始; vim +/string file: 打开file,并将光标停留在第一个找到的string上。 vim --remote file: 用已有的vim进程打开指定的文件。 如果你不想启用多个vim会话,这个很有用。但要注意,

How to include forward slash in vi search & replace

牧云@^-^@ 提交于 2019-12-28 02:39:48
问题 I have a file that contains the string usrbin . I want to search for usrbin and replace it with /usr/bin/ . I tried :%s/usrbin/usr/bin/g , but it's showing error E488: Trailing characters . How do I include a forward slash in a search and replace? 回答1: Here are two ways: escape the / which is the default substitute separator: :s/usrbin/\/usr\/bin use another substitute separator, e.g., using the hash # character: :s#usrbin#/usr/bin . Note that there are characters that you can't use as a