vi

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

怎甘沉沦 提交于 2019-11-27 20:55:40
" 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 打开文件并定位到第n行 . vim +/string file

Customising word separators in vi

浪尽此生 提交于 2019-11-27 18:41:34
vi treats dash - and space as word separators for commands such as dw and cw . Is there a way to add underscore _ as well? I quite often want to change part of a variable name containing underscores, such as changing src_branch to dest_branch . I end up counting characters and using s (like 3sdest ), but it would be much easier to use cw (like cwdest ). In case you're using vim, you can change that by setting the iskeyword option ( :he iskeyword ). If that is not an option, you can always use ct_ instead of counting. g33kz0r Is there a way to add underscore _ as well? :set iskeyword-=_ Anton

Indenting entire file in Vim without leaving current cursor location

孤街醉人 提交于 2019-11-27 18:26:07
问题 I already know that gg=G can indent the entire file on Vim. But this will make me go to the beginning of the file after indent. How can I indent the entire file and maintain the cursor at the same position? 回答1: See :h '' This will get you back to the first char on the line you start on: gg=G'' and this will get you back to the starting line and the starting column: gg=G`` I assume the second version, with the backtick, is the one you want. In practice I usually just use the double apostrophe

Easiest way to swap occurrences of two strings in Vim?

*爱你&永不变心* 提交于 2019-11-27 17:59:20
What is the easiest way to replace all occurrences of string_a with string_b while at the same time changing anything that was already string_b into string_a ? My current method is as follows: :s/string_a/string_c/g :s/string_b/string_a/g :s/string_c/string_b/g Although this works, it requires extra typing and seems inefficient. Does anybody know of a better way to do this? I'd do it like this: :%s/\v(foo|bar)/\={'foo':'bar','bar':'foo'}[submatch(0)]/g But that's too much typing, so I'd do this: function! Mirror(dict) for [key, value] in items(a:dict) let a:dict[value] = key endfor return a

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

北城以北 提交于 2019-11-27 17:11:37
原文: 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 do I use vi keys in ipython under *nix?

最后都变了- 提交于 2019-11-27 17:09:20
Currently in Bash I use set -o vi to enable vi mode in my bash prompt. How do I get this going in ipython? Note: If an answer applies to all *nix, I'll remove the OS X from the title :) In case someone's wandering in here recently, IPython 5.0 switched from readline to prompt_toolkit , so an updated answer to this question is to pass an option: $ ipython --TerminalInteractiveShell.editing_mode=vi ... or to set it globally in the profile configuration ( ~/.ipython/profile_default/ipython_config.py ; create it with ipython profile create if you don't have it) with: c.TerminalInteractiveShell

vim快捷键-01

烂漫一生 提交于 2019-11-27 16:57:56
1、 vi与vim   vim是vi的优化版,大多数的 vi 的软连接就是vim,但vim才是编辑器之神 2、 打开文件   vim 文件名 +行数(注意:有+号)   例: vim hello.sh +16 3、 打开文件并定位到文件末尾(光标会定位在文件末尾)   vim 文件名 +   例:vim .hello.sh.swp (以 . 开头的文件为影藏文件) 来源: https://www.cnblogs.com/SBJBA/p/11371011.html

vim最常用命令

大憨熊 提交于 2019-11-27 16:36:28
vi/vim常用命令汇总 vi/vim概述 vi/vim是Linux和Unix下的一款非常强大的编辑器,vim是vi的增强 版,命令更加多种和复杂,但是最常用的也就是那几个。 vi有三种模式 命令行模式 命令行模式就是刚开始输入vi 进入vi编辑器时所看到的模式,这时可以进行对光标的移动,字符的 删除等操作 插入模式 按i或o或a进入插入模式,这时可以编辑文档了,任意编辑文档都可以。 底行模式 底行模式主要对文档进行保存,重命名,查找等操作 vi/vim最常用命令 保存文件 :wq 按esc退出插入模式,输入:wq 保存文件并且退出vi编辑 :w filename 以指定的文件名存储文件,但是不退出vi编辑 :q! 强制退出vi编辑器,不保存修改内容 光标移动 shift+$ 移动到当前行 行尾 shift+^ 移动到当前行 行首 e 移动到下一个字符末尾 b 移动到上一个字符开头位置 w 移动到下一个字符开头 l 移动到该 行第几个字符位置,例如:3l 数字0 移动光标到文章开头 删除字符 x 删除光标所在字符 x 删除从光标所在字符起向后删除n个字符,例如2x X 大写X删除光标所在前一个字符 X 删除除了光标所在字符之外的n个字符,例如3X dd 删除光标所在行 dd 从当前行起删除n行,例如3dd 复制字符 yw 复制单个字符到缓冲区中 yw 复制n个字符到缓冲区中 yy

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

…衆ロ難τιáo~ 提交于 2019-11-27 16:35:51
原文: 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 do I move to end of line in Vim?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 16:33:09
I know how to generally move around in command mode, specifically, jumping to lines, etc. But what is the command to jump to the end of the line that I am currently on? Just the $ (dollar sign) key. You can use A to move to the end of the line and switch to editing mode (Append). To jump the last non-blank character, you can press g then _ keys. The opposite of A is I (Insert mode at beginning of line), as an aside. Pressing just the ^ will place your cursor at the beginning of the line. Rob Wells As lots of people have said: $ gets you to the end of the line but also: ^ or _ gets you to the