Vim, less, and other editors


less

f/z: forward one window
b/w: backward one window
/pattern: forward searching
?pattern: backward searching
g: jump to first line
G: jump to last line


Vim

TO DO:
vim configure:

  • show syntax color
  • show line number
  • convert tab into space
    -tab = 4 spaces

http://coolshell.cn/articles/5426.html : 简明 Vim 练级攻略(from coolshell)

  • You can enter insert mode from normal mode by pressing the i key. Now, text you type will be inserted. You can enter visual mode from normal mode by pressing the v key. That starts a visual selection.

-------- moving cursor ----------

  • w moves one word forward; 3w moves three words forward; b moves one word backward; 3b moves three words backwards.
  • gg moves to first line, G moves to last line, 123G moves to line number 123.
  • More moving: 8k moves eight lines up, 5j moves five lines down, 4l moves four characters right, 23h moves 23 characters left.

--------- undo and redo -----------

  • Use u to undo and Ctrl-r to redo, multiple times.

---------- copy, paste, delete ---------------

  • Use v to enter into visual mode to select lines
  • Use d or x to delete / cut
  • After selecting: y will "yank" (copy); p will "put" (paste) at a new location (after the cursor; use P for before the cursor). Use y in visual mode and p in normal mode.
  • Convenience commands: dd delete current line; yy yank current line.

----------- search ----------

  • Searching: /regularexpression to search forward, ?regularexpression search backward; press n for next hit, or N for previous.

======== vim 分屏 ==========
http://coolshell.cn/articles/1679.html

vim分屏功能总结
vim的分屏功能

总结起来,基本都是ctrl+w然后加上某一个按键字母,触发一个功能。
(1)在shell里打开几个文件并且分屏:
  vim -On file1 file2 ...
  vim -on file1 file2 ...

大O表示垂直分割(vertical),小o表示水平分割(默认horizontal),后面的n表示分几个屏,实际上我觉得不用写,默认按后面要分割的文件数来决定分几个屏。
(2)在vim里打开一个分屏:
  创建空白分屏:
  :new
  打开任意文件:
  :vsplit(:vsp) filename
  :sp(split) filename
  打开当前文件:
  ctrl+w 和 s(split)
  ctrl+w 和 v(vsplit)

(3)关闭一个分屏:
  :only 或者 ctrl+w 和 o取消其它分屏,只保留当前分屏
  ctrl+w 和 c(close)
  只剩最后一个分屏以后推出:
  ctrl+w 和 q(quit)
(4)移动光标,也就是切换分屏;也可以移动分屏,比如将左分屏移动到右边。
  ctrl+w 和 w(各种切换,只有两个分屏的时候还是比较方便的)
  ctrl+w 和 h(H) 左
  ctrl+w 和 j(J) 下
  ctrl+w 和 k(K) 上
  ctrl+w 和 l(L) 右
(5)最后就是改变分屏尺寸的操作了。
  ctrl+w 和 < 左
  ctrl+w 和 > 右
  ctrl+w 和 + 上
  ctrl+w 和 - 下
  ctrl+w 和 = 恢复均等

http://coolshell.cn/articles/5426.html : 简明 Vim 练级攻略(from coolshell)

  • You can enter insert mode from normal mode by pressing the i key. Now, text you type will be inserted. You can enter visual mode from normal mode by pressing the v key. That starts a visual selection.

-------- moving cursor ----------

  • w moves one word forward; 3w moves three words forward; b moves one word backward; 3b moves three words backwards.
  • gg moves to first line, G moves to last line, 123G moves to line number 123.
  • More moving: 8k moves eight lines up, 5j moves five lines down, 4l moves four characters right, 23h moves 23 characters left.

--------- undo and redo -----------

  • Use u to undo and Ctrl-r to redo, multiple times.

---------- copy, paste, delete ---------------

  • Use v to enter into visual mode to select lines
  • Use d or x to delete / cut
  • After selecting: y will "yank" (copy); p will "put" (paste) at a new location (after the cursor; use P for before the cursor). Use y in visual mode and p in normal mode.
  • Convenience commands: dd delete current line; yy yank current line.

----------- search ----------

  • Searching: /regularexpression to search forward, ?regularexpression search backward; press n for next hit, or N for previous.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一个人到底该以怎样的心态去面对他人呢?
    长安书苑阅读 278评论 2 1
  • 晚上在小区里玩的时候,跟一个十二岁的小男生聊天儿,刚上初一,刚参加完军训,翔宇中学宝山校区。我只问了他上几年级...
    Fang70阅读 291评论 0 1
  • 终于在今晚上完成了新家整理的70% 喜欢每夜蟋蟀声入眠 "旧男友"被说回到身边了 因为我知道爱本身就足以代表一切 ...
    TS小西阅读 140评论 3 1