`

Vim Usage:Happy Vimming

 
阅读更多
I am a slow walker,but i never walk backwards.


(Hyp:
let me make a summaries for the usage of Vim^^)


Log Time:2011_10_26 AM

1.Modes

   Vim,by default,runs in a mode which does not let you begin typing(unlike notepad,Word,etc).
   Instead,vim begins in command mode.Each mode is accessed by pressing a key,and escape returns
   to command mode.The various modes are as follows.

   a).Insert mode:
   The mode that lets you type normally.When in command mode,vim allows you to start typing before
   the cursor(i/I),after the cursor(a/A),or in adjacent lines(o/O).
[
TAG001:
adjacent  [ə'dʒeisənt]      
a. 毗邻的,邻接的,靠近的,贴近的
{HYP--Custom Basic Useful Usages:

1.The two families live on adjacent streets.
这两家住在两条相邻的街上。
2.I find every limb is mutually shared by two adjacent folds.
我发现两个相邻褶皱共同拥有其中的一个翼。

}
]
   b)Visual mode:
   v allows you to highlight text,as you would by using a mouse in a graphical editor.
      i.Block:ctrl+V   Visual Block selects characters in a rectangular shape,controlled by the movement(h,j,k,l) keys.
      ii.Line:shift+V  Select entire lines at a time.

   c)Movement:
   h,j,k,l These four keys are located adjacent to each other on the keyboard,where the right hand sits.
   This is intentional;they seem to be a strange collection,but the arrangement allows easy movement of the cursor
   without having to move your hand to a mouse,or the the arrow keys.



   Vim deals with text by the character,word,line,or paragraph.
   With many commands,you can combine a command with one of the letters w,W,(for 'words'),
   b,B(for words,moving backwards from the cursor),or l (for lines).Simply pressing w,W,b,or B moves forward or
   backward by that amount while in command mode.The brackets, { and } move forward and backward one paragraph
   at a time.


2.Deleting text:


   d and x delete text.
   x removes one character at a  time;
   X deletes backwards.
   dw and dW delete words,whereas db and dB delete words backwards.
   dd deletes an entire line,and D deletes everything from the cursor to the end of the line.

3.Copy/Pasting text


a)"yanking" is the equivalent to copying,so named because you use the y key to copy selected text.
Anything highlighted (in Visual mode)will be placed into a buffer.There are other buffers available for your use,
named a-z.To use the registers,prefix the commands with a quotation mark ,",followed by the letter of the buffer.
For example,to yank into register q,the command is "qy.
Pressing yy grabs an entire line.

b)"pasting" puts the contents of a buffer back into the file being edited.
To paste,p pastes after the cursor,P before.Similar to yanking,prefixing the command with " and
a letter will paste from the specified buffer.

4.Files


a)Opening:
The most basic way to open a file is from the terminal,when launching vim.Once you are using vim,the :e command ,
followed by a filename,opens a file for reading.

b)Saving:The :w command writes your document to disk.Adding a name,i.e.  :w main.cpp will save to that filename.

c)Quitting:  :q quits vim.This can be used in conjunction with :w,to form the command :wq,which writes your file,then quits.


If you are editing a file and have not saved it when trying to quit or open a new file,
you will get a message saying No write since last change (use ! to override).
By appending an ! to the :e or  :q commands,you can discard any changes since you last save.

{HYP:SO ,by now,we have seen some basic tips about the usage of vim.
Now let's get to some advanced skills  of vim.}


Advanced Vim Features

1.The tilde (~) key will change the capitalization of the current selection(i.e.,'vim' becomes 'VIM')

2.Moving to the beginning or end of a line can  be accomplished with 0 and $,respectively.

3.By pressing m,followed by any letter a - z,you can save ("mark") a location in your document,and jump to it using the
apostrophe ' key,followed by the same letter.
This lets you jump to important points of a file quickly.

4. Syntax highlighting can be turned on using the :syntax on command.
It can be turned off with:syntax off.

5.Vim allows you to run terminal commands without having to quit vim.
Pressing :!,followed by a terminal command,vim will execute the command,
the return you to the vim window.
For example,:!ls will print out the contents of the current directory,prompt you to hit Enter,then return to vim.

6.The .vimrc file resides in your home directory ,and contains a list of preferences.
In this file,you can set your favorite options(syntax highlighting ,etc) to be set every time vim is launched.

7.  u undoes the last action.ctrl+r redoes it.

8. The / command allows you to search a file for a string.
/linux will search the document for the string 'linux'.
Pressing n jumps to the next occurrence of the string ,and N moves backwards.

9.Folding

In a class such as cs225,Folding is one of the most useful features of vim.
Folding lets you 'hide' areas of your document,which your can collapse and expand at will.
Vim creates folds based on syntax,indentation or you can create them mannually.
When dealing with a language such as C++,
vim's syntax detection does an excellent job of creating folds.

a)Enabling folds:
Folds are turned on and off with the  :set foldenable and :set nofoldenable options.
b)Fold method:
There are three primary methods of doing this;syntax,indent,manual.
Toggle between them with  :set foldmethod=OPTION,i.e. :set foldmethod=syntax.
c)Folding Commands:There are several ways to expand and collapse folds.

za toggles a fold.
zc and zC close a fold,and recursively close all folds that contain the area under the cursor.
z0 and zO opens a fold ,and recursively opens all folds under the cursor.
zR and zM open all folds in a document,and close all folds in a document.
In manual folding mode,zfNj creates a fold from the cursor down N lines.
zd deletes the fold at the cursor,and zE deletes all folds.


10.Tabs

   New versions of Vim allow you to open up separate tabs with different documents in each .
   To create a tab,use the command:tabnew.
   The commands :tabnext and  :tabprev move to the next and previous open tabs.



11.Split Windows

   Vim lets you divide your window into multiple areas to edit different regions of the same file,or different file concurrently.

   :split divides the window in half horizontally.
   Prefixing it with a number ,such as :20 split,creates a split of 20 characters.

   :vsplit divides the window vertically.

   Pressing ctrl+w,followed by one of the direction(j,k,l) keys,will move focus from one area to another.

   The quit(:q) command will close a split area.


(HYP:
So,really vim seems to be a powerful and lightweight editor,also gets its unique characteristics.
Just make it my editor from now.
No notepad ,no word. no npp++.no vs ,no delphi for editing text.
)










  • vim.pdf (46.9 KB)
  • 下载次数: 0
分享到:
评论

相关推荐

    Go-vimgrep命令类似于vim的:vimgrep行为

    在Go语言的开发环境中,有时候我们可能需要对多个文件进行搜索和查找特定的代码模式,这时,`Go-vimgrep`命令就派上了用场。它模仿了Vim编辑器中的`:vimgrep`功能,使得在代码库中进行全局搜索变得更加高效和便捷。 ...

    Vim实战:使用Vim实现图像分类任务

    Vim作为一种高效的视觉模型,具有计算和内存效率高、处理高分辨率图像能力强等优点。这使得Vim成为下一代视觉基础模型的理想选择。 本文使用Vim模型实现图像分类任务,模型选择最小的vim_tiny_patch16_224_...

    vim插件:omnicppcomplete-0.41.zip、taglist_46_vim.zip、vim-autocomplpop.zip三合一

    vim常用插件: 1. omnicppcomplete-0.41.zip 2. taglist_46_vim.zip 3. vim-autocomplpop.zip

    vimIde:将Vim设置为IDE

    杀虫剂利用coc插件打造开发环境以下参考Java IDEC / C ++ #termux apt安装clang #vim :CocInstall coc-clangdPython #termux apt安装python 点安装绝地#阿里巴巴代理商pip配置设置global.index-url #vim :...

    vim:个人Vim个人资料

    编辑~/.vimrc文件,里面加一行: so ~/.vim/vim/init.vimso ~/.vim/vim/skywind.vim视窗:新建D:\github目录,把项目克隆到D:\github\vim下面: d:cd \githubgit clone https://github.com/skywind3000/vim.git...

    Vim-X:Vim-X 的只读发布历史

    Vim::X - Vim 中 Perl 编程的糖果 版本 版本 1.0.1 概要 package Vim::X::Plugin::MostUsedVariable; use strict; use warnings; use Vim::X; sub MostUsedVariable :Vim { my %var; for my $line ( vim_lines ) ...

    pop-punk.vim::guitar: vim 的深色、高对比度配色方案

    " .vimrc" example using vim-plugcall plug#begin ( ' ~/.vimplugins ' )Plug ' bignimbus/pop-punk.vim '" ...call plug#end ()colorscheme ' pop-punk '" pop-punk ANSI colors for vim terminallet g: terminal...

    vimsed:vimsed脚本使vim的行为类似于sed。 句法

    vimsed脚本使vim的行为类似于sed。 句法: vimsed " <vim> " vimsed会将标准输入“管道”到标准输出,首先通过运行击键对其进行修改。 警告:使用临时文件~/vimsedin , ~/vimsedcmd.vim和~/vimsedout 。 例子: ...

    msys运行vim依赖

    标题“msys运行vim依赖”涉及的是在MSYS(Minimal SYStem)环境下成功运行Vim编辑器所需的一些关键依赖。MSYS是一个轻量级的Unix-like环境,它为Windows提供了一个模拟POSIX接口,使得用户可以在Windows上编译和运行...

    vimwiki:vimwiki文件

    **vimwiki: 使用 Vim 编辑的个人Wiki系统** vimwiki 是一个基于 Vim 的轻量级个人Wiki系统,它允许用户使用 Vim 的强大编辑功能创建、管理和组织文本笔记。这个系统充分利用了 Vim 的快捷键和命令,使得创建和维护...

    vim-smartinput:Vim插件:提供智能输入助手

    Vim是一款非常强大的文本编辑器,它以其高度可定制性和高效的操作方式深受程序员和文本处理者的喜爱。在Vim的世界里,插件是提升编辑体验的重要工具,它们能为Vim添加各种功能,如代码补全、语法高亮、文件管理等。...

    VMware vCenter Java包 vim25.jar

    Developer vCenter for java

    vim jeffy插件和配置

    linux下用vim编辑器配合jeffy插件实现比较顺手的编程环境。Jeffy插件和配置文件(.vim):代码高亮 自动提示等。 vim版本必须大于7.1。 1,备份下vim配置文件(可选) 2,解压jeffy-vim.zip 和里面的jeffy-vim-read.tar...

    vim-fakeclip:Vim插件:提供伪“剪贴板”寄存器

    **vim-fakeclip:Vim插件:提供伪“剪贴板”寄存器** `vim-fakeclip` 是一个针对 Vim 编辑器的插件,它的主要功能是为 Vim 提供一种模拟剪贴板的功能,即所谓的“伪剪贴板”寄存器。在 Vim 中,剪贴板通常通过 `+` ...

    vimtips 学习VIM的理想资源

    学习vim: http://www.vim.org/ O cial site http://chronos.cs.msu.su/vim/newsgroup.html Newsgroup and Usenet http://groups.yahoo.com/group/vim Speci c newsgroup http://u.webring.com/hub?ring=vim VIM ...

    vimconfig:我来了

    【vimconfig:我来了】 在IT领域,尤其是程序员和开发者的世界里,Vim是一个非常流行的文本编辑器。它以其高效、可高度定制化的特性而受到众多程序员的喜爱。"vimconfig:我来了"这个标题暗示我们将深入探讨如何配置...

    vim-arpeggio:Vim插件:同时按下的按键的映射

    Vim是一款强大的文本编辑器,深受程序员和系统管理员的喜爱,其可扩展性是它的一大亮点。`vim-arpeggio` 是一个Vim插件,专为处理同时按下多个按键的映射而设计,极大地增强了Vim的键绑定功能。本文将深入探讨这个...

Global site tag (gtag.js) - Google Analytics