Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Vim 讓你寫 Ruby 的速度飛起來

19,088 views

Published on

身為工程師,一定聽過編輯器之神 - Vim, 而很多人雖然使用過 Vim,卻因為學習門檻而沒有繼續深入,無法體會到它 的威力,實在有點可惜,因此講者這次嘗試用較易於理解的方式來說明 Vim 最核心的功能——編輯,當理解了 Vim 編輯的設計方式之後,使用者將可以輕易的做出數以千計的操作組合,來進行精確且直覺的游標移動與文字編輯,同時也會介紹 Vim 在開發 Ruby & Rails 上適合的配置。

內容不會涉及太多 Vim 獨有的功能,希望除了 Vim 使用者外,其他編輯器的使用者也能夠透過 Vim mode 來體驗 Vim 的強大之處。

Published in: Software
  • Be the first to comment

Vim 讓你寫 Ruby 的速度飛起來

  1. 1. Vim 讓你寫 Ruby 的速 度⾶飛起來來
  2. 2. 洪梓凱 HzChris 後端⼯工程師 @ 財報狗 hzchirs @ Github
  3. 3. Rubyists 愛⽤用什什麼 Editor?
  4. 4. 好 Vim,不學嗎?
  5. 5. 原本的編輯器⽤用的好好 的,爲什什麼要⽤用 Vim ?
  6. 6. hello world
  7. 7. hello world move to world
  8. 8. ⼀一般的⽅方式
  9. 9. hello world
  10. 10. hello world →
  11. 11. hello world → * 2
  12. 12. hello world → * 3
  13. 13. hello world → * 4
  14. 14. hello world → * 5
  15. 15. hello world → * 6
  16. 16. Vim 的⽅方式
  17. 17. hello world
  18. 18. hello world w
  19. 19. w -> word forward
  20. 20. hello world delete hello
  21. 21. ⼀一般的⽅方式
  22. 22. hello world
  23. 23. ello world delete
  24. 24. llo world delete * 2
  25. 25. lo world delete * 3
  26. 26. o world delete * 4
  27. 27. world delete * 5
  28. 28. world delete * 6
  29. 29. Vim 的⽅方式
  30. 30. hello world
  31. 31. hello world d
  32. 32. world dw
  33. 33. d w -> delete word forward
  34. 34. d 2 w?
  35. 35. hello world
  36. 36. hello world d
  37. 37. hello world d2
  38. 38. d2w
  39. 39. def foo(bar, baz) end
  40. 40. def foo(bar, baz) end delete inner (
  41. 41. def foo(bar, baz) end d
  42. 42. def foo(bar, baz) end di
  43. 43. def foo() end di(
  44. 44. d i ( -> delete inner (
  45. 45. def foo(bar, baz) end
  46. 46. def foo(bar, baz) end change inner (
  47. 47. def foo(bar, baz) end c
  48. 48. def foo(bar, baz) end ci
  49. 49. def foo() end ci(
  50. 50. c i ( -> change inner (
  51. 51. Vim 提供了了類似⾃自然語 ⾔言的指令,能夠⽤用直覺 的⽅方式對⽂文件進⾏行行編輯
  52. 52. ⾃自然語⾔言 名詞、動詞、介詞、 副詞、形容詞.... Vim 語⾔言 operator motion text-object
  53. 53. operator + motion 動詞 名詞 d w delete word forward Vim 的語⾔言
  54. 54. c → change d → delete (cut) y → yank(copy) v → visual(select) = → ⾃自動縮排 > → 增加縮排 < → 減少縮排 operator
  55. 55. motion w → word forward 2w → 2 words forward b → word backward e → end of word
  56. 56. f → find t → til 找到⽬目標的前⼀一個字 / → 搜尋下⼀一個符合的 pattern motion
  57. 57. 恭喜你! 你解鎖了了 42 個 Vim 的快捷鍵 7 operators x 6 motion
  58. 58. ⼩小技巧: 使⽤用 . 來來重複上⼀一次的指令
  59. 59. 提升修改的精確度 text-object
  60. 60. text-object Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun. Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.
  61. 61. text-object Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun. Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.
  62. 62. text-object Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun. Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.
  63. 63. text-object Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun. Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.
  64. 64. text-object Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun. Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.
  65. 65. text object: 介詞 + 名詞 i → inner a → a w → word p → paragraph s → sentence b( [ { “ ‘ ` t → block
  66. 66. hello world inner word
  67. 67. hello world a word
  68. 68. inner paragraph def foo end def bar end
  69. 69. a paragraph def foo end def bar end
  70. 70. inner tag <span>Hello </span>
  71. 71. a tag <span>Hello </span>
  72. 72. operator + text object 操作 物件 d i( delete inner (
  73. 73. 擴充 motion、operator 與 text-object
  74. 74. vim-easymotion • <leader><leader>w • <leader><leader>b
  75. 75. vim-surround
  76. 76. text-object • vim-ruby • m -> method object • M -> class object • indent-object • i -> indent object
  77. 77. 經驗分享 • 善⽤用 :help • 練習盲打,速度達到約 50wpm(words per minute) 即可 • ⼀一天學兩兩個指令,⼀一週之後就能明顯 感受到⽣生產⼒力力的提升
  78. 78. Q & A
  79. 79. Thank you!

×