`
DavyJones2010
  • 浏览: 151862 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Vim: Basic operation introduction

    博客分类:
  • Vim
阅读更多

Overall View:



1. Move the cursor:

1) j  --> move down

2) k --> move up

3) h --> move forward

4) l  --> move afterward

5) 0 --> move to the start of current line

6) $ --> move to the end of current line

7) w --> move to the start of next word

8) e --> move to the end of next word

9) 3w --> move 3 words afterward

10) 3e --> move 3 words afterward

 

2. Deletion

1) x   --> delete single character at the cursor

2)dw --> delete whole word at the cursor including all the spaces after the word.

3)d$ --> delete all characters including and after the current cursor. 

4) d3w --> delete 3 words afterward

5) d3e --> delete 3 words afterward

6) dd -->   delete current line

7) d2d --> delete 2 lines afterward including current line

8) 2dd --> delete 2 lines afterward including current line. same with d2d

9) ce   --> delete  the left character in the word after & including the current cursor

10) c$

 

3. Insertion

1)  i  --> insert before current cursor

2)  I -->  insert before the first character of current line.

3) a --> insert after current cursor

4) A --> insert after the last character of current line.

    w - until the start of the next word, EXCLUDING its first character.
    e - to the end of the current word, INCLUDING the last character.
    $ - to the end of the line, INCLUDING the last character.

5) o --> open a line BELOW the cursor and start Insert mode

6) O --> open a line ABOVE the cursor and start Insert mode

4) Exit

1) :q! --> quit without saving changes

2) :wq --> quit and saving all changes

 

5) Undo

1) u --> undo single operation

2) U --> undo all the operations on a line.

  1. To delete from the cursor up to the next word type:    dw
  2. To delete from the cursor to the end of a line type:    d$
  3. To delete a whole line type:    dd

  4. To repeat a motion prepend it with a number:   2w
  5. The format for a change command is:
               operator   [number]   motion
     where:
       operator - is what to do, such as  d  for delete
       [number] - is an optional count to repeat the motion
       motion   - moves over the text to operate on, such as  w (word),
		  $ (to the end of line), etc.

  6. To move to the start of the line use a zero:  0

  7. To undo previous actions, type: 	       u  (lowercase u)
     To undo all the changes on a line, type:  U  (capital U)
     To undo the undo's, type:		       CTRL-R

 

6) Paste

1) p --> paste after current line

2) P --> paste before current line

 

7) Replace

1) r --> replace single character on the cursor

2) R --> replace more than one character on the cursor.

3) :s/thee/the    --> replace the word 'thee' with 'the' in current line. only replace once.

4) :s/thee/the/g --> replace the word 'thee' with 'the' in current line. replace all occurence in current line.

5) :%s/thee/the/g --> replace the word 'thee' with 'the' replace all occurence in current file.

     type   :#,#s/old/new/g    where #,# are the line numbers of the range
                               of lines where the substitution is to be done.
     Type   :%s/old/new/g      to change every occurrence in the whole file.
     Type   :%s/old/new/gc     to find every occurrence in the whole file,
     			       with a prompt whether to substitute or not.

 

8) Position

1) G --> Go to the last line of the file

2) gg --> Go to the first line of the file

3) ctrl + g --> Also called CTRL-G, show the detail position information for current line.

4) 123G  --> Move cursor to line 123.

5) Ctrl + b --> Move backward one screen

6) Ctrl + f --> Move forward one screen

 

9) Search

1) /errroor<ENTER> --> find the word "errroor" in file search FORWARD for the phrase.

2) ?errroor<ENTER> --> find the word "errroor" in file search BACKWARD for the phrase.

3) n       --> go to next match 

4) N       --> go to prev match

5) %      --> go to the corresponding character. {}, [], ()

                  This is very useful in debugging a program with unmatched parentheses!

6) ctrl+o --> go to older position

7) ctrl+i  --> go to newer position

 

10) Select

1) v    --> start visual selection

 

11) Copy

1) y   --> yank (copy)

2) yw --> copy word

3) ye --> copy word

4) y$ --> copy till the end of line

5) yy --> copy whole line

 

12) Set command

Typing ":set xxx" sets the option "xxx".  Some options are:
  	'ic' 'ignorecase'	ignore upper/lower case when searching
	'is' 'incsearch'	show partial matches for a search phrase
	'hls' 'hlsearch'	highlight all matching phrases
     You can either use the long or the short option name.
  • 大小: 236.7 KB
分享到:
评论

相关推荐

    vim basic operation

    **vim基础操作** vim(Vi IMproved)是一款强大的文本编辑器,被广泛应用于Linux和Unix-like操作系统中。它以其高效、灵活和可扩展性而受到程序员和系统管理员的喜爱。了解并掌握vim的基本操作是每个IT从业者必备的...

    Practical Vim: Edit Text at the Speed of Thought

    Vim is a fast and efficient text editor that will make you a faster and more efficient developer. It's available on almost every OS--if you master the techniques in this book, you'll never need ...

    vim_files_files

    Vim(Vi IMproved)是Linux、Unix、Mac OS X及Windows等操作系统中的一款强大的文本编辑器,由 Bram Moolenaar 开发,基于原始的Vi编辑器。它以其高效、可高度定制化和功能丰富而闻名,是程序员和系统管理员的首选...

    msys运行vim依赖

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

    Learn-vim:Vim实操教程(Learning Vim)Vim实用教程

    因此,为了同时满足学习和操作的需求,项目中的文件都采用了Markdown格式,既可以按照说明文档来​​阅读,也可以用Vim:文件进行实际操作(建议采用一部分)。 如何使用 进入控制台 clone项目到本地 git clone git@...

    oob-vim:Zer4tul的vim配置

    对于vim: ln -s ~/.oob-vim ~/.vim 用于NeoVim ln -s ~/.oob-vim ~/.config/nvim 安装插件 对于vim: vim +PlugInstall +qa 对于NeoVim: nvim +PlugInstall +qa 自动安装 为vim和NeoVim安装oob-vim: curl -...

    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...

    Mastering-Vim:Packt发行的Mastering Vim

    掌握Vim 这是Packt发行的的代码存储库。 使用Vim和Neovim构建软件开发环境 这本书是关于什么的? Vim是一个无处不在的文本编辑器,可用于所有编程语言。 它具有广泛的插件系统,并与许多工具集成。 Vim为程序员...

    vim-ide:将vim设置为IDE

    #termux apt安装clang #vim :CocInstall coc-clangd Python #termux apt安装python 点安装绝地#vim :CocInstall安装coc-python 高朗 #termux apt安装golang #vim :cocInstall安装coc-go 网路 #termux ...

    yajs.vim:YAJS.vim:Vim的另一个JavaScript语法

    YAJS:另一个JavaScript语法Vim的另一个JavaScript语法文件。 主要区别: 使用“ javascript”作为组名的前缀,而不是“ javaScript”或“ JavaScript”。 与一起。 识别Web API和DOM关键字。 基于与完美搭配删除旧...

    salt-vim:用于安装和配置 vim 的盐状态模块

    Salt-VIM 这是一个用于在服务器上安装的 salt state 模块。... salt '*' state.sls vim样本Struts数据: 我希望在... vim: {% if grains['os_family'] == 'Debian' %} config_base_dir: /etc/vim {% endif %} autocmds:

    .vim:Vim配置

    .vim:Vim配置

    neoline.vim:Neovim的状态专线专注于美观和性能:white_heavy_check_mark:

    使用带有 light主题和neoline.vim: 安装 :mage: 在Vim / NeoVim配置文件上添加以下行: Plug ' https://github.com/adelarsq/neoline.vim ' 然后打开编辑器并使用PlugInstall安装。 在Vim / NeoVim配置文件上...

    lucariox.vim:定制的vim和neovim配色方案灵感来自lucario和深蓝色元素

    lucariox.vim 定制vim和neovim从激发颜色方案Lucario与混合Darkblue元件和一些额外的比特。 原始Lucario配色方案: Darkblue配色方案是默认的一部分vim分布。 此外,它还定义了嵌入式终端的颜色,变量类型,... ...

    alpine-vim:“ dockerized”的Vim

    alpine-vim:“ dockerized”的Vim

    Linux基本指令08. Vim文本编辑器的基本编辑2(whereis, which, 软连结概念, vim: 搜寻 删除 打开栏号 undo redo)

    [Ubuntu][教學]_Linux基本指令#08.__Vim文字編輯器的基本編輯2(whereis,_which,_軟連結概念

Global site tag (gtag.js) - Google Analytics