vim

get到的vim技巧,vim真是神器啊

北慕城南 提交于 2019-12-21 23:21:42
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 主要是寄存器操作,简直神器, 首先,说用寄存器的命令要知道,C-R (ctrl+r) 比如说用a寄存器,就要说按Ctrl+r a 这样子. 0-9 a-z (只有小写) 都是vim的寄存器, 其中,1-9 是删除寄存器,分别记录上n次删除的内容,比如,我要复制上5次删除的内容使用 "5p 就可以了, 0呢,上一次复制的内容,yy自动存入, a-z是具名寄存器,比如yy想存入a中,就是用 "ayy 这样子. 这些寄存器是可以混用的, 比如 / 和 ? 我想搜上4次删除的内容,就可以用 /<CTRL+R>4 回车, 这样子哦, 输入/"4 只能搜"4这样的字符,这个和vim的配置相关. 希望能够帮助大家. 下面是我工作中实际用的的技巧,十分方便,里面注明的使用场景 vim技巧 查找的技巧(这个比较基本,随时可用) / 从当前位置向下查找 ? 从当前位置向上查找 选中当期光标所在的 单词 然后向 下 查找 # 选中当前光标所在的 单词 然后向 上 查找 g* 选中光标所在的 单词 然后部分匹配向 下 查找 g# 选中光标所在的 单词 然后部分匹配向 上 查找 部分匹配的意思是不区分大小写的匹配 场景(向上查找用于找统一文件的定义,先用m做一个标记,找到后方便跳回来,向下找用于查看这边变量的变化) 有关使用 搜索 和

linux中 vi / vim显示行号或取消行号命令

一曲冷凌霜 提交于 2019-12-21 22:18:22
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> linux中 vi / vim显示行号或取消行号命令 1. 显示行号 :set number 或者 :set nu 2. 取消行号显示 :set nu! 3. 每次打开都显示行号 修改vi ~/.vimrc 文件,添加:set number 来源: oschina 链接: https://my.oschina.net/u/3367404/blog/2979127

vim打开文件时显示行号

不羁岁月 提交于 2019-12-21 22:18:02
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> vim打开文件是,默认不提示行号。 至于显示行号的用途,因人而异 linux下一个主机可能有N个账户。对于配置分为两种:仅配置当前账户,配置所有账户 vim配置文件路径(Centos 5.5 final ): /etc/vimrc 若当前账户目录下无vim配置文件,可以cp /etc/vimrc至相应目录。cp后,使用chmod 改变文件的用户组和用户,并mv vimrc .vimrc,将文件设为隐藏文件 一。更改所有账户配置 直接更改/etc/vimrc vim /etc/vimrc 在vimrc文件的最后添加 set nu 即可 wq退出。这样,不论使用哪个账号登陆,vim打开后都显示行号 二。为当前用户配置环境 找到当前用户的vimrc文件。若无此文件,建立此文件即可。 vim ~/.vimrc 打开文件后,在最后添加 set nu wq退出。 再次用vim打开即可显示行号。 以上总结仅在文本模式下实现。在GUI未做测试。搜索得到的结果为:在GUI下,需要更改gvimrc(GUI下未作测试,仅供参考) 显示行号的效果图,对于代码内容及格式有见解请留言,嘿嘿 来源: oschina 链接: https://my.oschina.net/u/1757911/blog/552873

如何在Centos下设置Vim的永久显示行号功能?

送分小仙女□ 提交于 2019-12-21 22:17:45
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 在Linux系统中,我们经常会使用vi或vim命令,来操作文本,有时候,我们的脚本文件出了错误,会抛出一个带行号的异常,然后我们根据提示,重新打开,我们的源码进行查看,而这时候,如果你的vim没有设置显示行号功能,我们查找出问题的一行的代码,则非常不方便,不知道大家有没有遇到过这种情况。 解决办法如下: (1)cat -n 命令 能够一次性的显示文本的行号,便于我们观察,但是在编辑状态下,是不管用的 (2)配置vim的行号功能,这样就能在任何时候,编辑状态下,也快速定位行号 散仙,建议大家使用第二种方法,下面看下具体的配置方式; (1)root用户,直接编译 /etc/vimrc文件,在文件末尾添加如下两行设置命令: #显示行号 set nu #设置缩进 set tabstop= 4 (2)非root用户下,直接编辑 vi .vimrc文件,添加命令和(1)一样,保存,退出之后,我们再次使用vi命令,来编辑文件,就会显示行号了,例子如下: [search @dnode1 ~]$ vi word 1 i am hadoop 2 i am hadoop 3 i am lucene 4 i am hbase 5 i am hive 6 i am hive sql 7 i am pig 来源: oschina 链接:

vi-vim编辑器

六月ゝ 毕业季﹏ 提交于 2019-12-21 22:16:37
vim编辑器   系统管理员的重要工作就是得要修改与设定某些重要软件的配置文件,因此至少得要学会一种以上的文字接口的文件编辑器,在所有的Linux distributions 上头都会有的一套文书编辑器就是vi,而且很多软件默认也是使用是作为编辑器的接口,此外,Vim是进阶版的vi,vim不但可以用不同的颜色显示文字内容,还能够进行诸如shell script,Cprogram等程序编辑功能,你可以将Vin视为一种程序编辑器。 什么是vim?   Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。 简单的来说, vi 是老式的字处理器,不过功能已经很齐全了,但是还是有可以进步的地方。 vim 则可以说是程序开发者的一项很好用的工具。 vi/vim的使用   在Linux环境中输入 vi/vim+文件名 进入vim编辑环境。   基本上 vi/vim 共分为三种模式,分别是 命令模式(Command mode) , 输入模式(Insert mode) 和 底线命令模式(Last line mode) 。 这三种模式的作用分别是: 命令模式: 用户刚刚启动 vi/vim,便进入了命令模式。 此状态下敲击键盘动作会被Vim识别为命令,而非输入字符。比如我们此时按下i,并不会输入一个字符,i被当作了一个命令。

Converting Emacs/vim highlighting to TextMate (for SublimeText)

北城以北 提交于 2019-12-21 21:44:12
问题 I have syntax highlighting files for Pyret in vim (.vim) and emacs (.el) and would like to use them in Sublime Text (3). According to this answer and other research, Sublime Text style themes are written in TextMate format. There exists a tool to help convert from TextMate to Emacs, but I contacted the author and he isn't aware of any tools to help facilitate the opposite conversion. A similar question was asked (re: vim) but not answered a year ago: .vim syntax highlighting to textmate or

Commenting c++ codes in Vim

。_饼干妹妹 提交于 2019-12-21 21:34:34
问题 I want to map \c to comment the current line in vim (add '// ' to before the first non-blank to the line) and \d to delete the '// ' at the beginning of line(uncomment). I've added these two lines in my vimrc: imap \c <Esc>:s/^/\/\/ <CR>j$a imap \d <Esc>:s/^\/\/ /<CR>j$a but when I call this in this line: for (int i = 0; i < n; i++) then it is converted to: // for (int i = 0; i < n; i++) but I want to convert it to: // for (int i = 0; i < n; i++) one of the reasons I want this is that when I

How to let vim behave on Mac OS X as on Ubuntu?

柔情痞子 提交于 2019-12-21 20:29:11
问题 Recently I started using a Macbook Pro. Installed is Mountain Lion and so far everything is good. I'm coming from Ubuntu and being pretty much addicted to vim, I can't really stand how Mac Os X is treating vim. ;) For instance, if I use the mouse in Ubuntu to scroll up, the max I can scroll is the top of the file when a file is open. When I try that in Mac Os X, I scroll straight into the shell history. I'd like the Ubuntu behaviour better, because I find it easier and more logical (even

Define a syntax region which depends on the indentation level

99封情书 提交于 2019-12-21 19:58:14
问题 I'm trying to built a lighter syntax file for reStructuredText in Vim. In rst, literal blocks start when "::" is encountered at the end of a line: I'll show you some code:: if foo = bar then do_something() end Literal blocks end when indentation level is lowered. But, literal blocks can be inside other structures that are indented but not literal: .. important:: Some code for you inside this ".. important" directive:: Code comes here Back to normal text, but it is indented with respect to "..

How to get short option name from long option name in vim

夙愿已清 提交于 2019-12-21 17:48:04
问题 I have a list of vim long option names as strings (e.g. ["tabstop","shiftwidth"]). What would be the best way to convert it into a list containing only short names (e.g. ["ts,"sw"]). What about if the original list is a mix of short and long names? 回答1: :help options.txt :" retaining lines with a tag surrounded by quotes :g/^\s*\(\*'\w\+'\*\s*\)\+$/y A :winc n "ap Result: aleph al aleph Aleph allowrevins ari noallowrevins noari altkeymap akm noaltkeymap noakm ambiwidth ambw antialias anti