vi

VI Editor: Move to EOL instead of last character

浪尽此生 提交于 2019-12-04 11:43:04
问题 I'm most often finding myself having to work with plain old vi on minimalistic terminals that tend to act differently than the vim on big distros, and so the behavior trips me up. What I want to know is not how to move to the last character in the line, but one character past that. Because typing $ does NOT move the insertion cursor to the last character in the line, and this is easily proven. I'm using vi on MSYS right now. If I type in the line This is a test and hit esc , $ , i , and

vim in Cygwin replaces first character with 'g' on opening a file

夙愿已清 提交于 2019-12-04 10:45:34
I use vim in Cygwin terminal. It was working fine. Recently, I added a package in Cygwin which caused update of vim and some other components. Now when I open any file in vim, the first character in the file gets replaced with character 'g'. I tried removing .vimrc and all files in .vim folder in my home folder. But the problem persists. To understand the problem, I opened a file using 'vim -E'. On opening, I see the following at the bottom of the window: Entering Ex mode. Type "visual" to go to Normal mode. :]11;rgb:0000/0000/0000\ The key sequence rgb in vim would replace the first character

解决Swap file \".ceshi.c.swp\" already exists!问题

左心房为你撑大大i 提交于 2019-12-04 10:30:40
关于swp文件:使用vi,经常可以看到swp这个文件,那这个文件是怎么产生的呢,当你打开一个文件,vi就会生成这么一个.(filename)swp文件以备不测,如果你正常退出,那么这个.(filename)swp文件将会自动删除。 因此.(filename)swp文件就是你没有正常退出vi或者vim编辑器时留下来的!比如:强行关闭vi或vim时,电源突然断掉,或者你使用了Ctrl-zz。(正常的退出方式应该是Shift-ZZ) 这时候就会出现下面的情况了 解决办法 用下面的命令删除swp文件 rm .{your file name}.swp 例如:我的文件名是ceshi.c 那么就用这样的命令:rm .ceshi.c.swp (当然你前面也可以加-rf强制删除) 问: (vi 一个文件时怎么样可以不让它产生.swp文件?或不让他提示【“Swap file ".文件名.swp" already exists![O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit:】) 处理方法: 打开 vi /etc/vimrc 并在末尾添加 set noswapfile 后保存退出 OK 原文链接:https://blog.csdn.net/my_wade/article/details/46762625 来源: https://www.cnblogs

Vim / vi Survival Guide

可紊 提交于 2019-12-04 07:50:12
问题 What are the essential vim commands? What does a new-user need to know to keep themselves from getting into trouble? One command per comment, please. 回答1: What I find irreplaceable (because it works in vi also, unlike vim's visual mode) are marks. You can mark various spots with m (lower case) and then a letter of your choice (eg x). Then you go elsewhere, and can go back with ``x (backquote letter) to the exact spot, or with 'x` (apostrophe letter) to go to the line. These movements can be

Package(Plugin) Management for Vim

僤鯓⒐⒋嵵緔 提交于 2019-12-04 07:39:17
问题 Emacs 24 looks like it will have a package manager. What package management options are there for Vim? 回答1: I am now using VimPlug for my own Vim setup, and I definitely recommend it. Installation is very simple, and it is fast, pretty and effective! I used to recommend Vundle in this answer. But Vundle is no longer maintained, and there are better alternatives. 回答2: Plugin management for vim used to be a pain in the traditional way by spreading plugin files across the whole personal vim

Tabs and spaces in vim

試著忘記壹切 提交于 2019-12-04 07:39:15
问题 How do I prevent vim from replacing spaces with tabs when autoindent is on? An example: if I have two tabs and 7 spaces in the beginning of the line, and tabstop=3 , and I press Enter, the next line has four tabs and 1 space in the beginning, but I don't want that... 回答1: It is perhaps a good idea not to use tabs at all. :set expandtab If you want to replace all the tabs in your file to 3 spaces (which will look pretty similar to tabstop=3 ): :%s/^I/ / (where ^I is the TAB character) From the

VIM - Replace based on a search regex

谁说胖子不能爱 提交于 2019-12-04 07:39:11
问题 I've got a file with several (1000+) records like : lbc3.*' ssa2.*' lie1.*' sld0.*' ssdasd.*' I can find them all by : /s[w|l].*[0-9].*$ What i want to do is to replace the final part of each pattern found with \.*' I can't do :%s//s[w|l].*[0-9].*$/\\\\\.\*' because it'll replace all the string, and what i need is only replace the end of it from . ' to \. ' So the file output is llike : lbc3\\.*' ssa2\\.*' lie1\\.*' sld0\\.*' ssdasd\\.*' Thanks. 回答1: In general, the solution is to use a

Search for string and get count in vi editor

点点圈 提交于 2019-12-04 07:30:47
问题 I want to search for a string and find the number of occurrences in a file using the vi editor. 回答1: :g/xxxx/d This will delete all the lines with pattern, and report how many deleted. Undo to get them back after. 回答2: THE way is :%s/pattern//gn 回答3: You need the n flag. To count words use: :%s/\i\+/&/gn and a particular word: :%s/the/&/gn See count-items documentation section. If you simply type in: %s/pattern/pattern/g then the status line will give you the number of matches in vi as well.

Hide all (not)matching lines in Vim

陌路散爱 提交于 2019-12-04 07:29:38
问题 Is it possible to show/hide all matching lines in vi or Vim? Not highlight but just show only those lines. For example I have a text with word the word ERROR . How do I make it show only lines containing ERROR and how to show only lines without ERROR ? Is there a solution without deleting all matching lines and then just undoing it? 回答1: Do you know about the :global command? Does this do what you want? :g/ERROR and for the opposite: :g!/Error or equivalently: :v/Error 回答2: Another approach

In Vim/Vi, how do you move the cursor to the end of the previous word?

寵の児 提交于 2019-12-04 07:27:37
问题 In Vim's normal mode: e goes to the end of the next word w goes to the beginning of the next word b goes to the beginning of the previous word How do you move the cursor to the end of the previous word? 回答1: Unfortunately it's not a single key... but g e is what you're looking for, I think. 回答2: Try g e : ge Backward to the end of word [count] |inclusive|. *gE* gE Backward to the end of WORD [count] |inclusive|. 回答3: as seen on VIM manual (section 03.1), you can use g e to go to the end of