GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — note/note/vim/18.md at master · trialbox/note

Expand file tree

/

18.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
28 lines (20 loc) · 1.93 KB
/

18.md

Copy path

File metadata and controls

28 lines (20 loc) · 1.93 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

每日一Vim(18)Text-Object

前两节讲了Visual mode相关内容,这里提一个小问题,“如何选择一个单词?”3秒后...,你可能会使用命令vw,很不幸的是它会把下一个单词的首字母也选中。如果你足够细心的话,你会发现答案在之前的章节中讲过,命令是:viw。它的作用是选取一个单词(word),无论光标在这个单词的哪个位置都能选中整个单词,那么i到底有什么作用呢?这就是今天要讲解的内容。

Text-Object:可以指一个单词,一整句文本,抑或一对括号内的文本,甚至是html或xml标签内的文本,都可以抽象成Text-Object。与Text-Object紧密相关的两个命令就是a和i,啊?这两个命令不是append和insert吗?其实,a和i操作在Visual mode或者某些操作(比如:d,y等)后面就是另外一种效果了。例如,删除一个单词可以用daw或者diw。那么a与i又有什么区别呢?

** a会选择一个对象(an object)包括空格在内,而i只会选择一个对象的内部(an inner object)不包含空格。**

下面就是一些命令含义:

aw   a word
iw   inner word
aW   a WORD   
iW   inner WORD
as   a sentence
is   inner sentence
ap   a paragraph
ip   inner paragraph
a[|]   a[] block (这里的'|'是或的意思,也就是说'a['和'a]'都表示一个[]块)
'{} &al;>()与[]作用类似
at   a  tag (这里的tag可以是html或xml中任何标签对)
it   inner tag

比如在一个html文件中,当前光标在某个标签对的内容里头的时候,命令dat会把整个标签对包括内容都会删除,而dit只会删除标签对之间的内容,保留标签对。详细说明可以:help text-objecgts

转载请注明出处,谢谢合作!作者---zhijun

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.