vim: useful operations

enter different modes:

  • i :insert
  • v: visual
  • shift+v :visual line
  • control+v :visual block

quit different modes:

  • esc : quit insert
  • v :quit visual
  • shift+v :quit visual line
  • control+v :quit visual block

quit & save

  • :q :quit
  • :x :quit and save
  • :q! :force quit without saving

undo & redo

  • u :undo
  • control + r :redo after too much undo:

move the cursor

  • h :left
  • j :down
  • k :up
  • l :right
  • fX :pressing f and X together moves cursor to next 'X' in the same line (X is any character)
  • ; :repeat fX in same direction

search

  • :/text :search text
  • n :next matching
  • N :previous matching
  • ggn :jump to the first matching
  • GN :jump to the last matching
  • :/<text> : search your exact text
  • :^text :search text at beginning of one line

write lines to file/clipboard

  • :1,2w filename :write line 1-2 to a file
  • set clipboard=unnamed :add to .vimrc to share the Mac clipboard with vim
  • :1,2w !pbcopy : copy line 1-2
  • :r !pbpaste :paste the clipboard

references:

  1. Vim最少必要知识
  2. Vim基础-Markdown语法练习
  3. All the right moves
  4. Mac OS X clipboard sharing
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容