2019/07/14_NGS Data Analysis Course (Harvard Chan Bioinformatics Core)_5_vim初级

text editor: 可以分为:graphical user interface (GUI) text editors and command-line editors.

GUI: such as TextWrangler, Sublime, and Notepad++, which allow you to write and edit plain text documents.

vim is a command_line editor

链接:http://www.runoob.com/linux/linux-vim.html

 https://coolshell.cn/articles/5426.html

vim 以及在我们的opsin 里了。无需安装

#Vim Modes

Vim has two basic modes that will allow you to create documents and edit your text:

  • command mode (default mode): will allow you to save and quit the program (and execute other more advanced commands).

  • insert (or edit) mode: will allow you to write and edit text

一般情况下默认为command mode, 点击 i 即切换为insert mode. 即可输入编辑文档。输入完成,点击esc 即推出到command mode.

#Vim Saving and Quitting

To write to file (save), type :w. You can see the commands you type in the bottom left-hand corner of the screen.

Alternatively, we can write to file (save) and quit. Let’s do that by typing :wq. Now, you should have exited vim and returned back to your terminal window.

To edit your draft.txt document, open up the file again by calling vim and entering the file name: vim draft.txt. Change to insert mode and type a few more lines (you can move around the lines using the arrows on the keyboard). This time we decide to quit without saving by typing :q!

保存就是  :w, 或者我们可以:wq 退出。 如果想再次编辑,要先用vim 空格 文件名来调出文件,然后 i 切换到编辑模式, 输入完成后即:wq 保存退出。 或者直接 :q! 不保存直接退出。

#Vim Editing

为了更容易地区分行, 我们可以给以及编辑的文本加上行号。 即输入 : set number. Save the document.

相反,如果想去除行号就输入: set nonumber.

移动快捷键 While in command mode, try moving around the screen and familarizing yourself with some of these shortcuts:

keyaction
ggto move to top of file
Gto move to bottom of file
$to move to end of line
0to move to beginning of line
wto move to next word
bto move to previous word

In addition to shortcuts for navigation, vim also offers editing shortcuts such as:

keyaction
dwto delete word
ddto delete line
uto undo
Ctrl + rto redo
/patternto search for a pattern (n/N to move to next/previous match)
:%s/search/replace/gto search for a pattern and replace for all occurences

##Overview of vim commands

Vim modes:

keyaction
iinsert mode - to write and edit text
esccommand mode - to issue commands / shortcuts

Saving and quiting:

keyaction
:wto write to file (save)
:wqto write to file and quit
:q!to quit without saving

Shortcuts for navigation:

keyaction
ggto move to top of file
G   to move to bottom of file    
$to move to end of line
0to move to beginning of line
wto move to next word
bto move to previous word

Shortcuts for editing:

keyaction
dwto delete word
ddto delete line
uto undo
Ctrl + rto redo
:set numberto number lines
:set nonumberto remove line numbers
/patternto search for a pattern (n/N to move to next/previous match)
:%s/search/replace/gto search for a pattern and replace for all occurences

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值