vi

第十章 Vim程序编辑器学习

倖福魔咒の 提交于 2019-12-21 04:10:37
  1.Vim是进阶版的vi,vim不但可以用不同颜色显示文字内容,还能进行诸如shell script,C program等程序编辑功能。   区别:vi是老师的字处理器,不过功能已经很齐全,但还是有可以进步的地方。      vim则是一个“程序开发工具”而不是文字处理软件。在vi 的基础上加入了支持正则表达法的搜寻架构,多档案编辑、区块复制等等。 2、vi有一般模式,编辑模式、与指令列命令模式。 一般模式:可以用上下左右来移动光标,也可以使用“删除字符和删除整行”“复制和粘贴”来处理你的文件,但无法编辑文件。 编辑模式:在一般模式下,按下“i,I,o,O,a,A,r,R(取代)”等任何一个字母之后才会进入编辑模式。如果要回到一般模式,则按下“ESC”按键即可退出编辑模式。 指令列命令模式:在一般模式当中,键入“:/ ?”三个中任何一个按钮,就可将光标移动到最底下那一行。在这个模式当中,可以提供“搜寻资料、读取、存盘、大量取代字符、离开vi、显示行号”等动作 vi后面一定要加档名:vi test.txt.进入文档编辑模式 离开字符命令“:wq” ls -l:查看文件属性 一般模式下:h(向左)j(下)k(上)l(右)移动光标,如果想要进行多次移动的话,向下移动30行可使用“30j”或者"” "ctrl+f"="page down" "ctrl+b"="page up"

Vim error E510: Can't make backup file (add ! to override)

淺唱寂寞╮ 提交于 2019-12-21 03:32:39
问题 I am using Vim on Windows and decided to create a separate directory for all my backup files created by vim. I am using Vim from my command prompt and not using the vim GUI(gVim). I looked at this post and added the following lines in my _vimrc set backup set backupdir = D:\\VimTemp I have already created D:\VimTemp on my system. Now whenever I try to save changes to my file using :w I get the following error message "PenProperties.py" E510: Can't make backup file (add ! to override) I have

Vim error E510: Can't make backup file (add ! to override)

允我心安 提交于 2019-12-21 03:32:05
问题 I am using Vim on Windows and decided to create a separate directory for all my backup files created by vim. I am using Vim from my command prompt and not using the vim GUI(gVim). I looked at this post and added the following lines in my _vimrc set backup set backupdir = D:\\VimTemp I have already created D:\VimTemp on my system. Now whenever I try to save changes to my file using :w I get the following error message "PenProperties.py" E510: Can't make backup file (add ! to override) I have

Keyboard-only column block selection in GVim Win32, or why does Ctrl-Q not emulate Ctrl-V when mswin.vim is included?

痴心易碎 提交于 2019-12-21 03:18:43
问题 I want to be able to select columnar blocks using only the keyboard when I use GVim on Windows, but I do not seem to be able to do so when using gvim (7.2) on Windows XP. Edit: For convenience, it is preferable to make the selection with arrow keys as is commonly done in other versions of vi/vim. In a terminal, when using vim, to define a block, one may select columnar blocks by pressing Ctrl-V and by conveniently moving the cursor with the arrow keys . When using GVim on mswin, Ctrl-V is

How can I duplicate lines matching a pattern, and modify the second line, all in one command?

末鹿安然 提交于 2019-12-21 02:51:06
问题 I'm trying to add an attribute to a java class, using VIM as the editor. Therefore I thought I could use a command to ease my work with all the boilerplate code. Eg: All lines containing "atributeA", like this one this.attributeA=attributeA //basic constructor should turn into this.attributeA=attributeA //basic constructor this.attributeB=attributeB //basic constructor Is it possible? 回答1: Having the solution be a one-liner as a requirement seems a little odd, since you can assign any

open last modified file in the directory using vi

别说谁变了你拦得住时间么 提交于 2019-12-20 20:30:42
问题 I want a quick way to open the last modified file in the directory, perhaps in a form of alias. Currently, I do ls -ltr. Then copy-and-paste the filename Assume that I am using tcsh 回答1: vi `ls -tr | tail -1` 回答2: Creating an alias for the mentioned answer will avoid typing the command every time. Add below entry in .tcshrc file and reload. alias v='vi `ls -tr | tail -1`' To avoid going to log folder and executing the command, create below alias and reload. alias -- -='cd -' alias v='cd /path

Bash's vim mode, not vi

大憨熊 提交于 2019-12-20 12:10:50
问题 I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode? I mean when you are in a vi-like mode you can press v key and edit your commands in a fully functional vi editor's window but I would like to know how to force bash to start vim editor instead of vi because of the perks vim provides us (visual selection, additional commands etc)? 回答1: If you set EDITOR variable, in bash you can

How to write a VIM color scheme?

左心房为你撑大大i 提交于 2019-12-20 08:39:00
问题 I have been looking around for VIM color schemes and found some great ones out there (esp. by using http://code.google.com/p/vimcolorschemetest/), but I always want to change a few aspects of each one I find. So I've decided now that what I really want to do is make my own, or be able to customize the ones I find on the fly. Basically, what I want to know is: 1) How do I write a vim color scheme -- are there any good (quick) tutorials? 2) How do I add language-specific customizations? Like

How to write a VIM color scheme?

风流意气都作罢 提交于 2019-12-20 08:38:32
问题 I have been looking around for VIM color schemes and found some great ones out there (esp. by using http://code.google.com/p/vimcolorschemetest/), but I always want to change a few aspects of each one I find. So I've decided now that what I really want to do is make my own, or be able to customize the ones I find on the fly. Basically, what I want to know is: 1) How do I write a vim color scheme -- are there any good (quick) tutorials? 2) How do I add language-specific customizations? Like

Opening files in the same folder as the current file, in vim

蓝咒 提交于 2019-12-20 08:27:53
问题 In vim, when I have a buffer open, I often need to load another file in the same directory that file is in, but since I don't usually cd into it, the pwd is a parent folder, so I have to retype the path every time. Is there a shortcut for this? or a way to change the pwd to the directory the file is in? example: cd /src vi lib/foo/file.js lib/foo has two files: file.js and file2.js in vi: :e file2.js # doesn't work 回答1: Newer versions of vim have a autochdir command built in, if not you can