vim block vim_我如何學會愛Vim

vim block vim

by Sanchit Gera

通過Sanchit Gera

我如何學會愛Vim (How I learned to love Vim)

I’ve had a bitter-sweet relationship with Vim for a long time.

我與Vim有一段苦甜的戀情。

Over the last couple of years, I tried to learn Vim on several occasions. Each time, I ended up abandoning it. Instead, I would resort to my ‘primary’ text editor (usually Atom).

在過去的幾年中,我嘗試過幾次學習Vim。 每次,我最終都放棄了它。 相反,我會求助于我的“主要”文本編輯器(通常 原子 )。

But for a couple of weeks, I found myself unable to use Atom. This was due to an obscure connectivity issue. This made my setup completely useless over remote connections.

但是幾個星期后,我發現自己無法使用Atom。 這是由于模糊的連接問題 。 這使我的設置完全無法通過遠程連接使用。

After going through the five stages of grief, I decided to bite the bullet and try (again) to learn Vim. This time I forced myself to use Vim, and Vim alone.

在經歷了悲傷的五個階段之后,我決定忍痛忍受,并嘗試(再次)學習Vim。 這次我強迫自己使用Vim,并且單獨使用Vim。

I know — I could have easily switched to a more intuitive editor such as Sublime. Or I could even have used a fully fledged IDE like IntelliJ.

我知道—我可以很容易地切換到更直觀的編輯器,例如Sublime 。 或者我什至可以使用像IntelliJ這樣的成熟IDE。

Instead, I figured “what the hell”. Here are some of the things I learnt.

相反,我想到了“到底是什么”。 這是我學到的一些東西。

學習基礎 (Learning the basics)

In case it’s new to you, Vim is a seemingly archaic text editor. Its roots go back to a program call Vi, which appeared during the 1970s.

萬一您不熟悉它,Vim是一個看似古老的文本編輯器。 它的起源可以追溯到1970年代出現的Vi程序。

Part of Vim’s appeal — and annoyance — is due to the fact it is designed to work entirely with your keyboard. After all, point-and-click GUIs weren’t really a thing back when Vi was conceived.

Vim的吸引力之一(也是令人討厭的部分原因)是因為它旨在完全與您的鍵盤一起使用。 畢竟,在構思Vi時,點擊式GUI并不是真正的東西。

Vim instead uses modes. There are two main modes that can be used:

Vim改為使用mode 。 可以使用兩種主要模式:

  • Normal mode: this is the mode you use when you are navigating your files, or editing/manipulating them. This is mode for doing anything that does not involve typing new content. Most Vim commands are entered while in this mode.

    普通模式:這是您瀏覽文件或編輯/操作文件時使用的模式。 這是用于執行不涉及鍵入新內容的任何操作的模式。 在此模式下,大多數Vim命令都被輸入。
  • Insert mode: insert mode allows the input of new text. In this mode, Vim behaves more like a ‘normal’ text editor, such as Atom or Sublime. Minus the use of a mouse, of course.

    插入模式:插入模式允許輸入新文本。 在這種模式下,Vim的行為更像是“普通”文本編輯器,例如Atom或Sublime。 當然,要減去鼠標的使用。

Other modes exist in Vim too. One example is the visual mode, for selecting large chunks of text. Typically, these modes are used much less frequently.

Vim中也存在其他模式。 一個示例是可視模式,用于選擇大塊文本。 通常,這些模式的使用頻率要低得多。

Vim is normally used inside a Terminal emulator. However, standalone distributions exist. It is available on virtually all Unix and Linux systems. Vim’s grandfather, Vi, is part of the UNIX specification. It therefore comes preinstalled on all conforming systems.

Vim通常在終端仿真器內使用。 但是,存在獨立發行版。 幾乎所有Unix和Linux系統都可以使用它。 Vim的祖父Vi是UNIX規范的一部分。 因此,它預先安裝在所有符合標準的系統上。

可組合性 (Composability)

‘Composability’ is largely what makes Vim different to other editors. It gives Vim its own special language.

Vim與其他編輯器的不同之處在于“可組合性”。 它為Vim提供了自己的特殊語言。

It introduces the notion of nouns and verbs in the context of text editing and manipulation.

它在文本編輯和操作的上下文中介紹了名詞動詞的概念。

Verbs describe actions that you can take (such as delete, change, move).

動詞描述了您可以執行的操作(例如刪除,更改,移動)。

Nouns describe what is being acted upon (usually words, lines or places within the text).

名詞描述所采取的行動(通常是文字中的單詞,線條或位置)。

Some of the nouns/verbs commonly used include:

常用的一些名詞/動詞包括:

Verbs d: deletec: change (overwrite)y: yank (copy)>: indent<: unindent
Actionsh,j,k,l: left, down, up, rightw: next wordb: previous word0: start of line$: end of linei: inside (excluding the following character)a: around (including the encasing characters)

This list is non-exhaustive. There are tons and tons of key-bindings available. But you can achieve a lot with only the very basic ones. The idea is to chain together combinations of nouns, verbs and occasionally numbers. This allows you to create distinct actions to manipulate the text as needed.

此列表并不詳盡。 有成千上萬的鍵綁定可用。 但是,只有非常基本的內容,您才能取得很多成就。 這個想法是將名詞,動詞和偶然的數字組合在一起。 這使您可以創建不同的動作 根據需要操縱文本。

For example, to delete a word you type in the key combination dw.

例如,d elete A, ORD您在組合鍵鍵入dw

To delete 2 words from the current position, you type in d2w.

d elete2 瓦特從當前位置ORDS,你輸入d2w

To delete from the current position all the way to the end of the line, you type in d$.

要從當前位置一直刪除到行尾,請輸入d$

To delete everything inside a pair of parentheses, you would type di(. And on it goes.

d elete一切, n面一對括號,您可以鍵入di( 。而就不言而喻。

This method of working might not seem worth the hassle. But if you force yourself to use the combinations every day, they will become second nature. After a certain point, the speed you gain by reducing the number of keystrokes required to make a certain edit is absolutely thrilling. More on that next.

這種工作方法似乎不值得麻煩。 但是,如果您強迫自己每天使用這些組合,它們將成為第二天性。 在特定的點之后,通過減少進行特定編輯所需的擊鍵次數而獲得的速度絕對令人興奮。 接下來的更多內容。

Vim會上癮 (Vim is addictive)

Yes, I know. It’s a cliché. But bear with me.

是的我知道。 這是陳詞濫調。 但是,請忍受我。

Vim has a notorious learning curve. But once you get past the stage where you are constantly cursing your computer screen, using Vim is actually quite fun.

Vim有一個臭名昭著的學習曲線。 但是,一旦您走過了不斷咒罵計算機屏幕的階段,使用Vim實際上會很有趣。

Learning to use Vim’s cryptic commands lets you fly through the file editing process. After a while, it almost feels wrong to lift your fingers away from the home row on the keyboard, or even to use the mouse!

學習使用Vim的加密命令可以使您快速完成文件編輯過程。 一段時間后,將手指從鍵盤上的主行上抬起甚至使用鼠標幾乎感覺不對!

After only one month, I find myself missing Vim’s navigation system and other shortcuts while using my computer regularly.

僅一個月后,我發現自己在定期使用計算機時缺少Vim的導航系統和其他快捷方式。

In fact, at one point I considered experimenting with this extension to enable Vim keybindings while browsing the web. I know!

實際上,我曾經考慮過嘗試使用該擴展程序在瀏覽Web時啟用Vim鍵盤綁定。 我知道!

Fortunately, the programming community recognizes this. Most mainstream text editors have some way of enabling Vim keybindings. This puts ‘Vimmers’ out of their misery by giving them the best of both worlds.

幸運的是,編程社區認識到了這一點。 大多數主流的文本編輯器都有啟用Vim綁定的某種方式。 通過為他們提供兩全其美的選擇,使“ Vimmers”擺脫了痛苦。

給Vim一個戰斗的機會 (Giving Vim a fighting chance)

The key improving at Vim is to simply not use anything else. Instead, you should force yourself to do everything the Vim way.

Vim的關鍵改進是根本不使用其他任何東西。 相反,您應該強迫自己以Vim方式進行所有操作。

For example — when editing files in Vim, try not to resort to your old habits. Most people, when starting out, try to stay as far away from ‘normal mode’ as possible.

例如,在Vim中編輯文件時,請盡量不要訴諸舊習慣。 大多數人在開始時都嘗試盡可能遠離“正常模式”。

Instead, they try to spend as much time as they can in ‘insert mode’. In this mode, it is easy to feel more at home. It lets you get away with editing your file without learning anything new. But this is a mistake.

相反,他們嘗試在“插入”上花費盡可能多的時間 模式'。 在這種模式下,很容易有賓至如歸的感覺。 它使您無需學習任何新知識就可以輕松編輯文件。 但這是一個錯誤。

If you are genuinely interested in learning how to make Vim work for you, you have to put in some effort. This means taking the time to figure out the ‘right’ way to do something.

如果您真的有興趣學習如何使Vim為您工作,則必須付出一些努力。 這意味著要花時間找出做事的“正確”方法。

If you find yourself repeating keystrokes over and over again to achieve any task, stop. It is likely there is a better way to do what you are trying to do.

如果發現自己反復重復擊鍵以完成任何任務,請停止 。 可能有更好的方法來做您想做的事情。

Google it. Memorize it. Add it to your arsenal. It is far easier to learn new commands this way, compared to reading a list of commands and hoping you’ll need to use one of them.

谷歌一下。 記住。 將其添加到您的武器庫。 與閱讀命令列表并希望使用其中一個命令相比,用這種方法學習新命令要容易得多。

After a couple of days, you may develop an intuitive sense of when you are wasting keystrokes. Heed to your intuition.

幾天后,您可能會感覺到浪費按鍵的時間。 注意您的直覺。

欣賞(?)現代編輯 (Appreciate (?) modern editors)

Another big reason many people shy away from Vim is the seemingly ‘barebones’ nature of it all.

許多人都不愿使用Vim的另一個重要原因是這一切看起來像“準系統”。

By default, Vim comes with no plugins or nice-to-have features. And what Vim considers to be a ‘nice-to-have’ feature is probably very different to what programmers used to modern IDEs would consider ‘nice-to-have’.

默認情況下,Vim沒有插件或完善的功能。 Vim認為“必備”功能可能與習慣于現代IDE的程序員所認為的“必備”功能有很大不同。

Vim comes with barebones syntax highlighting (which is disabled by default). There is no line-numbering (again, this needs to be enabled separately).

Vim帶有準系統語法突出顯示(默認情況下處于禁用狀態)。 沒有行號(同樣,需要單獨啟用)。

No surprise, then, that things such as:

那么,諸如此類的事情就不足為奇了:

  • default Git integration

    默認的Git集成
  • ‘complete-as-you-go’ code completion

    “按需完成”代碼完成
  • automatic bracket completion

    自動完成括號
  • code snippets

    代碼段
  • custom color schemes

    自定義配色方案

…do not come pre-installed with Vim.

…不要預裝Vim。

This might seem like huge turn off — especially for programmers used to developing in powerful IDEs that do a lot of heavy lifting. Many come installed with a whole bunch of plugins and extensions designed specifically to make your workflow more efficient.

這似乎是一個巨大的挑戰,特別是對于那些習慣于使用功能強大的IDE進行大量繁重開發工作的程序員而言。 其中許多安裝有大量的插件和擴展程序,這些插件和擴展程序專門用于使您的工作流程更高效。

And there is some merit to this argument. Vim has its limitations.

這個論點有一些優點。 Vim有其局限性。

Yet on the flip-side — even though you appreciate what modern IDEs provide and the work that goes into building them — you also realize that most IDEs (and even modest editors such as Atom) bring with them a lot of bloat.

然而,另一方面,即使您欣賞現代IDE所提供的功能以及構建它們所要做的工作,您也意識到大多數IDE(甚至包括Atom這樣的謙虛編輯器)也給他們帶來了很多膨脹。

Advanced IDEs come jam-packed with features that are hardly used by average users.

高級IDE擠滿了普通用戶幾乎不使用的功能。

Learning to use Vim effectively is partly an exercise in working out which plugins are absolutely critical to your productivity. The key is to build an editor uniquely suited to your needs and workflow.

學習有效地使用Vim在某種程度上是確定哪些插件對您的生產力至關重要的練習。 關鍵是要構建一個完全適合您的需求和工作流程的編輯器。

In many cases, using a fully-fledged IDE makes perfect sense. The advanced features may far outweigh any benefits you get from using Vim.

在許多情況下,使用成熟的IDE是很有意義的。 高級功能可能遠遠超過使用Vim所帶來的任何好處。

But, this is something for you to figure out yourself.

但是,這是您要弄清楚自己的東西。

Despite its barebones nature, Vim has a thriving plugin ecosystem.

盡管Vim具有準系統性質,但它具有蓬勃發展的插件生態系統。

Vim has plugins for almost everything you can do with other editors. You just have to figure out which you need.

Vim具有幾乎可以與其他編輯器一起使用的所有功能的插件。 您只需要弄清楚您需要什么。

Something that surprised me was how far I can go with just a handful of plugins. My Vim setup currently comprises of around five or six ‘essential’ add-ons. I don’t really feel like I’m missing out on anything.

讓我感到驚訝的是,只有少數幾個插件我能走多遠。 我的Vim設置當前包含大約五個或六個“基本”加載項。 我真的不覺得我錯過任何事情。

Vim is not perfect. And it is definitely not for everybody.

Vim并不完美。 絕對不適合所有人。

But at the very least, learn enough of Vim in case you accidentally open it and can’t figure out how to quit…! ;)

但是至少,要對Vim有足夠的了解,以防萬一您不小心打開了它而又不知道該如何退出 ……! ;)

翻譯自: https://www.freecodecamp.org/news/how-i-learned-to-love-vim-ce3e058d57fb/

vim block vim

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/395189.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/395189.shtml
英文地址,請注明出處:http://en.pswp.cn/news/395189.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

AS 自定義 Gradle plugin 插件 案例 MD

Markdown版本筆記我的GitHub首頁我的博客我的微信我的郵箱MyAndroidBlogsbaiqiantaobaiqiantaobqt20094baiqiantaosina.comAS 自定義 Gradle plugin 插件 案例 MD 目錄 目錄AS 中自定義 Gradle plugin編寫插件傳遞參數發布插件到倉庫使用插件AS 中自定義 Gradle plugin 參考1 參…

學好Java的10個建議

1.克服慣性  將大塊任務細分為微任務。  2.關注大牛  你想學的或許是一門新的編程語言、應用框架或者是新的工具&#xff0c;一旦你確定了想要的是什么&#xff0c;就立刻去收集相應的優秀群體所做的一些優質的工作成果。這些可以從YouTube、Vimeo、HackerNews、各種博客…

中英文對照 —— 機械

0. 汽車 relay&#xff1a;繼電器&#xff0c;clutch&#xff1a;離合&#xff1b; motor&#xff1a;發動機&#xff08;馬達&#xff09;&#xff1b;檔位&#xff1a; park&#xff1a;停車擋braking&#xff1a;制動&#xff08;也就是剎車&#xff09;空擋&#xff1a;neu…

電子郵件鏈接mailto_“ 3個鏈接”電子郵件的歷史記錄以及曾經發送的每個鏈接的存檔...

電子郵件鏈接mailtoby Quincy Larson昆西拉爾森(Quincy Larson) “ 3個鏈接”電子郵件的歷史記錄以及曾經發送的每個鏈接的存檔 (The history of the “3 links” email and an archive of every link ever sent) It was March 2016. The freeCodeCamp community was growing.…

機票垂直搜索引擎的性能優化

機票垂直搜索引擎的性能優化 原文:機票垂直搜索引擎的性能優化一、行業背景與垂直搜索我們先了解一下機票的行業背景&#xff0c;下圖是由中航信統計的數據&#xff0c;藍色的曲線代表平均每公里的票價&#xff0c;紅色曲線指的是客運量。從2011年到2016年&#xff0c;無論是國…

2015國內征信機構大數據整合能力對比

自2001年起&#xff0c;大陸地區現代企業征信業進入在競爭中發展的階段&#xff0c;信用問題開始得到社會各界的廣泛關注&#xff0c;許多政府和民間投資的企業征信機構攜帶大量資本如雨后春筍般出現。 隨著企業征信行業環境不斷改善&#xff0c;信息透明度低的問題日益凸顯。大…

Unity3D 裝備系統學習Inventory Pro 2.1.2 基礎篇

前言 前一篇 Unity3D 裝備系統學習Inventory Pro 2.1.2 總結 基本泛泛的對于Inventory Pro 這個插件進行了講解&#xff0c;主要是想提煉下通用裝備系統結構和類體系。前兩天又讀了另一個插件 C# Inventory-uGui v2.0.1的源碼&#xff08;應該也是老外寫的&#xff09;&#xf…

Java項目問題_Java項目出現的問題01----學習

0 運行環境MyEcplise2016Tomcat8.01今天在html的表格提交跳轉時發現&#xff0c;想要提交到自己寫servlet程序中&#xff0c;卻發現總是出錯http://localhost:8080/Test4/Test4/fail.html多出一個項目路徑/Test4&#xff0c;但是程序沒有任何問題&#xff0c;最后發現是在Ecpli…

express-cli入門_使用Express.js入門

express-cli入門by Victor Ofoegbu由Victor Ofoegbu 使用Express.js入門 (Getting off the ground with Express.js) 使用Node.js框架編寫Web應用 (Writing web apps with the Node.js framework) A common moment of truth is when you develop a lot of applications that n…

《瘋狂前端開發講義jQuery+Angular+Bootstrap前端開發實踐》學習筆記

《瘋狂前端開發講義jQueryAngularBootstrap前端開發實踐》學習筆記 二〇一九年二月十三日星期三2時28分54秒 前提&#xff1a;本書適合有初步HTML、CSS、JavaScript基礎的讀者&#xff0c;或對企業應用前端開發不太熟悉的開發人員。 第1章&#xff1a;前端開發與Ajax技術 要點&…

混合云:公共云和私有云之間取得平衡的方式?

在可預見的未來&#xff0c;混合云是現實的&#xff0c;但真正的收獲是試圖找出企業最終朝向公共或私人資源是否平衡。 你在與任何技術供應商溝通時&#xff0c;也許會涉及到數據中心&#xff0c;但大多會提到云計算的三種方式&#xff1a;私有云&#xff0c;公共云&#xff0c…

騰騰流氓,云云更流氓(問微信怎樣接入支付寶支付),手賤的趕緊點,你會感謝我的...

草原上的兩匹馬&#xff01; 打從當年微信開始布局公眾號之初時&#xff0c;估計就已經想到了與支付寶正面沖突的場面&#xff0c;所以微信先來個瞞天過海&#xff0c;在春晚搞了個微信紅包&#xff0c;那叫一個火呀&#xff0c;此時的云云隱隱感覺到些許不安。 早期的微信開發…

java中的string是什么_什么是String

2017-07-28String和StringBufString namenew String("HuangWeiFeng");System。out。println(name"is my name");看似已經很精簡了&#xff0c;其實并非如此。為了生成二進制的代碼&#xff0c;要進行如下的步驟和操作&#xff1a;(1) 生成新的字符串 new S…

詳解華為與三星專利之爭 律師稱可能會打持久戰

華為技術有限公司(下稱“華為”)起訴三星&#xff0c;在近期中國企業起訴外企的“潮流”中掀起不小的漩渦。 “叫好聲”認為&#xff0c;這是已經擁有專利積累的中國企業在國際舞臺上的一次“實力亮相”&#xff0c;這件事本身就是中國制造業的勝利&#xff1b;“陰謀論者”認為…

租金 預測_如何預測租金并優化租賃期限,從而節省資金

租金 預測by Zhen Liu劉震 如何預測租金并優化租賃期限&#xff0c;從而節省資金 (How to Predict Rent and Optimize Your Lease Duration So You Can Save Money) In my last post, we talked about how to pick the best month to sign the lease based on seasonality. No…

java system load_關于java的System.load 和 System.loadLibrary

關于兩者的區別(參見http://blog.csdn.net/ring0hx/article/details/3242245)System.load 參數為庫文件的絕對路徑&#xff0c;可以是任意路徑。System.loadLibrary方法load的為相對路徑&#xff0c;即在java.library.path定義下的lib文件&#xff0c;文件名會更具不同的系統實…

東進技術南亞創捷

深圳市東進技術在其海外市場拓展中取得又一驕人戰績&#xff0c;于四月下旬與印度One97通信公司簽訂了長期戰略合作協議&#xff0c;One97將全面采用東進的全系列產品。同時簽訂的一期采購計劃&#xff0c;總裝機端口數約3萬線。該合約主要涉及東進技術的領先主打產品——Keygo…

如何在5分鐘內通過身份驗證構建RESTful API —全部從命令行(第1部分)

by Niharika Singh由Niharika Singh 如何在5分鐘內通過身份驗證構建RESTful API —全部從命令行(第1部分) (How to Build a RESTful API with Authentication in 5 minutes — all from your command line (Part 1)) If the title of this article excites you, then my frien…

MD5與SHA1

一、MD5 MD5消息摘要算法&#xff08;英語&#xff1a;MD5 Message-Digest Algorithm&#xff09;&#xff0c;一種被廣泛使用的密碼散列函數&#xff0c;可以產生出一個128位&#xff08;16字節&#xff09;的散列值&#xff08;hash value&#xff09;&#xff0c;用于確保信…

java基本類型的默認值及其取值范圍

轉載于:https://www.cnblogs.com/billyu/p/5843845.html