vi

The way to distinguish command-mode and insert-mode in Bash's Vi command line editing

百般思念 提交于 2019-11-29 20:34:18
I'm always little bit confused when bash in vi-mode is switched to insert-mode, because it doesn't give any tip about used mode (command or edit). Is there any way to distinguish mods? May be automatic change of cursor color or something like that? in /etc/inputrc (or ~/.inputrc) add this: set show-mode-in-prompt on this will prefix your prompt with + while in insert-mode, and : while in command mode in bash 4.3 EDIT: in the latest version of bash 4.4, you will instead get a prompt prefixed with "(ins)" or "(cmd)" by default. but, you can change that: set vi-ins-mode-string "+" set vi-cmd-mode

Returning to previous line with Vim

拥有回忆 提交于 2019-11-29 20:33:05
I was wondering if there's a way to return to the previous line you were on in Vim. Say, for example, I'm writing C code and I just wanted to add an #include at the top of the page: I press gg and go to the top, add the #include , and then I want to return to the line I left off of. Is this possible in Vim? Benoit Yes. You can use `` in order to jump between the last two positions. Otherwise, Ctrl + O and Ctrl + I can help you. See :help CTRL-I . Use a mark: ma marks the spot (before the gg ) `a brings you back. 来源: https://stackoverflow.com/questions/4837532/returning-to-previous-line-with

Standard python interpreter has a vi command mode?

烂漫一生 提交于 2019-11-29 20:27:21
this is going to sound pretty ignorant, but: I was working a bit in the python interpreter (python 2.4 on RHEL 5.3), and suddenly found myself in what seems to be a 'vi command mode'. That is, I can edit previous commands with typical vi key bindings, going left with h, deleting with x... I love it - the only thing is, I don't know how I got here (perhaps it's through one of the modules I've imported: pylab/matplotlib?). Can anyone shed some light on how to enable this mode in the interpreter? Ctrl-Alt-J switches from Emacs mode to Vi mode in readline programs . Alternatively add "set editing

Navigating in Vim's Command Mode

别说谁变了你拦得住时间么 提交于 2019-11-29 20:14:49
I am a long time emacs user learning Vim. Emacs lets me navigate in the mini-buffer (where I issue commands like C-x C-s) using the same navigation keyboard shortcuts as in any other buffer. For example, I can navigate forward one character using C-f, even while in the mini-buffer. I could also use the arrow keys, but they are too far away. Is there any keyboard shortcut to navigate in Vim's command mode (:), without using the arrow keys -- equivalent to emacs C-f, C-b? Thanks. Boldewyn Adding to Greg Hewgill's answer, you can use q: to open the command-line window, where you have any Vim

Vim yanking range of lines

大城市里の小女人 提交于 2019-11-29 20:14:26
I'm a C# developer who has just recently decided to expand my knowledge of the tools available to me. The first tool I've decided to learn is Vi/Vim. Everything has been going well so far, but there are a couple of questions I can't seem to find the answer to: Lets say I wanted to yank a range of lines. I know there are many ways of doing so, but I would like to do it by line number. I figured it would be similar to how the substitute commands work, something like 81,91y . Is there a way to do this? I'm a little confused about the g command in normal mode. It seems to do a myriad of things and

20190917-01VI/VIM编辑器

試著忘記壹切 提交于 2019-11-29 20:05:14
VI是Unix 操作系统和类Unix操作系统中最通用的文本编辑器。 VIM编辑器是从VI发展出来的一个性能更强大的文本编辑器。可以主动的以字体颜色便被语法的正确性,方便程序设计。VIM与VI编辑器完全兼容。 一般模式 以vi打开一个档案就直接进入一般模式了(这是默认的模式)。在这个模式中,你可以使用上下左右按键来移动光标,你可以使用删除字符或删除整行来处理档案内容,也可以使用复制、粘贴来处理你的文件数据。 表 1-1 常用语法 语法 功能描述 yy 复制 光标当前一行 y 数字 y 复制一段(从第几行到第几行) p 箭头移动到目的行 粘贴 u 撤销上一步 dd 删除 光标当前行 d 数字 d 删除光标(含)后多少行 x 删除一个字母,相当于 del , 向后删 X 删除一个字母,相当于 Backspace ,向前删 yw 复制一个词 dw 删除一个词 shift+^ 移动到行头 shift+$ 移动到行尾 gg 或者 1+G 移动到页头 G 移动到页尾 数字+G(先输入数字,在按 G ) 移动到目标行 编辑模式 在一般模式中可以进行删除、复制、粘贴等动作,但是无法编辑文件内容!要等到你按下i I o O a A等任何一个字母后才会进入编辑模式。 注意,通常在Linux中,按下这些按键是,在画面的坐下方会出现INSERT或者REPLACE的字样,此时可以进行编辑

Is there a command in Vim/Vi to move the cursor to the end of a search highlight?

点点圈 提交于 2019-11-29 20:01:26
Are there any commands in Vim/Vi to move within a selected search segment? For instance, if I search for a word, are there any commands to motion the cursor to the end of the highlighted segment? Say I have a word, "FishTaco" and I want to search for all instances of "Fish" and insert something after it. I know I could do a global replace, but what if I want to only make the change in a couple non-sequential instances? I could see where it would be convenient to be able to motion the cursor to the end of the current highlighted segment to perform an action. You can do it with this: /Fish/e The

Running vi in adb under Windows

别来无恙 提交于 2019-11-29 19:33:55
问题 Very occasionally, I will want to edit a file, say /system/build.prop or /etc/hosts on my Android device. I find that the easiest way to do it is: c:\> adb shell $ su # vi /etc/hosts This works fine if I'm using Linux. However, attempting to run vi on my phone when using Windows results in a borked vi screen with strange characters. I'm assuming this is because cmd doesn't support ANSI control characters. Is there any way to fix this (e.g., a cmd alternative that does the job)? 回答1: You can

Confusion about vim folding - how to disable?

允我心安 提交于 2019-11-29 19:24:56
When I open the file it looks like this: or even this When I open all folds, they are closed again when I navigated to another buffer and came back. To be able to work with it, I have to apply zR each time when opening a buffer. I have these set up in .vimrc : set foldlevelstart=99 set foldlevel=99 Please point me on how to disable the folding, or at least making the navigation to another buffer not to close the opened ones. You're not alone. set nofoldenable " disable folding The easiest way to disable (and enable) folding on the fly is zi . zi is the normal mode command that toggles

Anyone know of any (free / open source) VI integration for Visual Studio?

爱⌒轻易说出口 提交于 2019-11-29 19:13:06
vi is for cool kids. ViEmu - Not Free but great Vim emulation. Visual_Studio.vim - Allows you to manage visual studio from Vim. Using GVim as the Visual Studio Editor After @joe's answer, Jared Parsons created the great VsVim . It's been featured on Visual Studio Gallery . It's a ready extension package. I downloaded it, ran the file and it worked out of the box. It's free, too. Starting with Visual Studio 2010 you can use VsVim. It's a free extension available on the extension gallery. Source code is hosted on github http://github.com/jaredpar/VsVim http://visualstudiogallery.msdn.microsoft