博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Learn to speak vim – verbs, nouns, and modifiers!
阅读量:4153 次
发布时间:2019-05-25

本文共 2148 字,大约阅读时间需要 7 分钟。

Using vim is like talking to your editor in ‘verb modifier object’ sentences, turned into acronyms

  • learn some verbs: v (visual), c (change), d (delete), y (yank/copy). these are the most important. there are others
  • learn some modifiers: i (inside), a (around), t (till..finds a character), f (find..like till except including the char), / (search..find a string/regex)
  • learn some text objects: w (word), s (sentence) p (paragraph) b (block/parentheses), t (tag, works for html/xml) there are others

To move efficiently in vim, don’t try to do anything by pressing keys many times, instead speak to the editor in sentences

  • delete the current word: diw (delete inside word)
  • change current sentence: cis (change inside sentence)
  • change a string inside quotes: ci” (change inside quote)
  • change until next occurrence of ‘foo’: c/foo (change search foo)
  • change everything from here to the letter X: ctX
  • visually select this paragraph: vap (visual around paragraph)

If you understand the verbs and objects you’re dealing with, you will soon realize that adding a new plugin and learning a new verb or noun exponentially increases your productivity, as you can now apply it in all the sentences you already know. It’s just like learning a language.

Let’s add some new text object plugins!

  • install surround.vim: - you get a new noun, the ‘surround’ (s or S)
    • visually select a word and surround it with quotes: viwS”
    • change surround from single quote to double quote: cs’”
  • install – you get a new noun, the ‘ruby block’ (r)
    • delete current ruby block: dir (delete inside ruby block)
    • visually select a ruby function: var (visual around ruby block)
    • visually select the innards of a function: vir (visual inside ruby block)
  • install – new verb: gc (go comment)
    • comment the current ruby method: gcar (go comment around ruby)

Now go out and learn a new verb or noun every day!

Love this article? Here are some more you might like :)

Want an exceptionally curated collection of vim plugins and shortcuts?

Check out an early beta preview of my which includes text object plugins for ruby blocks(r), indents(i), dates(da/df), function arguments(a), and ruby symbols(:)

转载地址:http://idmti.baihongyu.com/

你可能感兴趣的文章
thinkpad密码忘记
查看>>
socket的半包,粘包与分包的问题
查看>>
epoll使用详解(精髓)
查看>>
主线程等待线程池所有任务完成
查看>>
线程池-生产消费者
查看>>
HDU 4323 bk树 编辑距离
查看>>
Java异常处理
查看>>
CountDownLatch
查看>>
二叉树的定义
查看>>
__FILE__,__LINE__
查看>>
redis cluster
查看>>
auto_ptr和shared_ptr
查看>>
Windows8.1 64bit环境下搭建深度学习平台之CUDA安装与配置
查看>>
CUDA在Windows下的软件开发环境搭建
查看>>
高性能网络编程技术
查看>>
Convolutional Neural Networks卷积神经网络
查看>>
深度神经网络DNN的多GPU数据并行框架 及其在语音识别的应用
查看>>
如何调试bash脚本
查看>>
读写二进制文件
查看>>
make 调试和传参
查看>>