Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cthierauf-edits #13

Merged
merged 5 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions rst/en/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ Cheatsheet & examples

So here we go, we now have everything needed to make a good start with |vim|. It should be enough to use it on a daily basis. It's the most important thing to do if you want to successfully use |vim|: developing the habit of using it everyday. Once you'll have this habit, everything should seem natural to you.

The aim of this chapter is to provide you with a reference for the most common things you'll have to do with |vim| so that, when you are lost, you know where to search for help. This chapters contains two parts. The first one is a set of Q/A covering the most common problems that newbies are facing. The goal is to answer this kind of question: "f**k, how can I do this, it was so simple with my old editor". The second is a non-exhaustive list of the most useful |vim| commands.
The aim of this chapter is to provide you with a reference for the most common things you'll have to do with |vim| so that, when you are lost, you know where to search for help. This chapter contains two parts. The first one is a set of Q/A covering the most common problems that beginners face. The goal is to answer the question of "f**k, how can I do this, it was so simple with my old editor". The second is a non-exhaustive list of the most useful |vim| commands.

Questions / Answers
===================

How to quit |vim|?
------------------
How do I quit |vim|?
---------------------

First you need to be sure to be in normal mode. If you don't know how to be sure that you are in normal mode, just press |ttesc| or |ttsemicolon| (depending on your configuration) multiple times and you should be in normal mode. Then, type :vimcmd:`:q` to exit |vim|. The problem is that most of the times, |vim| will no let you quit like that. For example, if you have unsaved changes, it will not let you quit. You can cancel your modifications by using :vimcmd:`!` like that: :vimcmd:`:q!`. You can also save your modifications and save like that: :vimcmd:`:wq`.
First you need to be in normal mode. If you don't know if you are in normal mode, just press |ttesc| or |ttsemicolon| (depending on your configuration) multiple times. This should bring you to normal mode. Then, type :vimcmd:`:q` to exit |vim|. The problem is that most of the time, |vim| will not let you quit immediately. For example, if you have unsaved changes, |vim| will not let you quit. You can cancel your modifications by using :vimcmd:`!` like this: :vimcmd:`:q!`. You can also save your modifications and save like this: :vimcmd:`:wq`.

How to save as?
---------------
How do I 'save as'?
-------------------

In normal mode, if you type :vimcmd:`:w`, |vim| will by default save your modifications into the current file. If you want to use another filename to "save as", you just need to specify it after :vimcmd:`w` like that: :vimcmd:`:w myfile.txt`. |vim| will save your file under the name *myfile.txt*. On the other hand, |vim| will not open *myfile.txt*, it will stay on the previous file.
In normal mode, if you type :vimcmd:`:w`, |vim| will by default save your modifications into the current file. If you want to use another filename to "save as", you just need to specify it after :vimcmd:`w` like this: :vimcmd:`:w myfile.txt`. |vim| will save your file under the name *myfile.txt*. However, be aware that |vim| will not open *myfile.txt*, it will stay on the previous file.

If you want |vim| to save under the filename *myfile.txt* and then open the file in the current buffer, you will have to use :vimcmd:`:sav myfile.txt`.

How to copy/cut paste?
----------------------
How do I copy/cut and paste?
----------------------------

This one is easy, there is already a full chapter on it, cf. :ref:`moving`.
This one is easy, and there is already a full chapter on it: :ref:`moving`.

In short:

Expand All @@ -33,16 +33,16 @@ In short:
* Copy using |tty| or cut using |ttx| or |ttd|,
* Paste after the cursor using |ttp| or before using |ttP|.

How to create a new file?
-------------------------
How do I create a new file?
---------------------------


The traditional way to create a file is to type, in normal mode, :vimcmd:`:e myfile.txt` to open an empty buffer. Then, save your buffer using :vimcmd:`:w`. Il will be saved as ``myfile.txt`` in the current directory.

You can also use Lusty Explorer (cf. :ref:`seclusty`). To do so, launch it using ``,lr`` or ``,lf`` (supposing that your leader key is ``,``), type the name of the file you want to create and then press |ttctrl| and |tte| at the same time. You can then save as above.

Undo/redo
---------
How do I undo/redo?
-------------------

To undo, just press |ttu| while in normal mode. To undo your undo (and so, to redo) press |ttctrl| and |ttr| at the same time.

Expand All @@ -63,8 +63,8 @@ Expected result Action
**Save as root** :vimcmd:`:w !sudo tee %`
=================================================== ==================================== ============

Moves
-----
Movement
--------

=============================================================== ===========
Expected result Action
Expand Down
40 changes: 20 additions & 20 deletions rst/en/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
Introduction
************

When you need to write or to code, you have to choose a text editor, and a very good one. They are many text editors available out there, but very few of them are more than 40 years old. It's the case of *Emacs* (http://www.gnu.org/software/emacs/), *Vi* and its improved successor |vim| (http://www.vim.org). They were created in the 70's and are still used a lot nowadays. You may have already noticed that it's not thanks to the beauty of their website or the efficiency of their communication. Here are some **reasons for their success**:
When you need to write or to code, you have to choose a text editor, and a very good one. They are many text editors available out there, but very few of them are more than 40 years old. It's the case of *Emacs* (http://www.gnu.org/software/emacs/), *Vi*, and its improved successor |vim| (http://www.vim.org). They were created in the 70's and are still used a lot nowadays. You may have already noticed that it's not thanks to the beauty of their website or the efficiency of their communication. Here are some **reasons for their success**:

**Forever**
You learn them once and you use them forever. In a world where languages and technologies are constantly changing, it's a real chance to be able to invest on the long term.
You learn them once and you use them forever. In a world where languages and technologies are constantly changing, learning vim is a real chance to invest in a skill you'll be able to use forever.

**Everywhere**
They are available for each and every possible platform : Mac Os X, Windows, GNU/Linux, BSD, and it's always been the case.
They are available for each and every possible platform : Mac Os X, Windows, GNU/Linux, BSD, and so on, and it's always been that way.

**Efficient**
Thanks to their features (like the extensive use of the keyboard), you can edit and write text as fast as your thoughts.

**For everything**
They allow you to edit everything and anything. When you'll use another programming language, or another markup language, you'll not have to change your editor. Of course, this book has been written using |vim| (and the `ReST Markup <http://sphinx-doc.org/rest.html>`_).
They allow you to edit everything and anything. When you'll use another programming language, or another markup language, you won't have to change your editor. Of course, this book has been written using |vim| (and the `ReST Markup <http://sphinx-doc.org/rest.html>`_).

Yet, these text editors are difficult to learn. Not that they are harder than anything else, not that you can't handle it, but rather because there is no smart way out there to learn them for now. So, here we are.

The aim of this book is to address this gap by guiding you through your discovery of |vim|. I'll put *Emacs* aside from now and I'll focus on |vim|. If you want to know more about this **Editor war**, be sure to check the `Wikipedia page <http://en.wikipedia.org/wiki/Editor_war>`_. This book doesn't claim to be a reference book about |vim|. There are already a lot of good references on the subject like `A byte of Vim <http://swaroopch.com/notes/vim/>`_. However, it claims to reduce the entry barrier to get used to |vim|. In my opinion, the most difficult thing about learning |vim| is not getting discouraged and finding a way to use it while learning it step by step. We all have to get things done with our text editor on a daily basis, that's why losing all your productivity when switching to |vim| is not possible
The aim of this book is to address this gap by guiding you through your discovery of |vim|. I'll put *Emacs* aside from now and I'll focus on |vim|. If you want to know more about this **Editor war**, be sure to check the `Wikipedia page <http://en.wikipedia.org/wiki/Editor_war>`_. This book doesn't claim to be a reference book about |vim|. There are already a lot of good references on the subject like `A byte of Vim <http://swaroopch.com/notes/vim/>`_. However, it claims to reduce the entry barrier to get used to |vim|. In my opinion, the most difficult thing about learning |vim| is not getting discouraged while finding a way to use it, learning |vim| step by step. We all have to get things done with our text editor on a daily basis, that's why losing all your productivity when switching to |vim| is not an option.

I'm sure you'll find a lot of people who will tell you: "Just do it cold turkey", "You'll see, it's hard at the beginning, but time will help". True, but you’ll still have the problem of trying to remain productive on a daily basis. The approach of this book is the following:

Expand All @@ -36,21 +36,21 @@ For who?

Every person having to produce text (code, book, reports, slideshows, …) regularly. Developers are of course concerned, but it's not only about them.

For example, you are a:
For example, if you are a:

**Student**
If you want to impress your future boss with your resume, it's a must. It's a proof of seriousness to see that a student took the time to learn |vim| on its own. Moreover, you'll have a unique tool to write all what you'll have to write (and that you'll be able to use for the rest of your career): your LaTeX reports, your slideshows, your code (if you need Word or LibreOffice to write you reports, it's time to use `LaTeX <http://en.wikipedia.org/wiki/LaTeX>`_, `Markdown <http://en.wikipedia.org/wiki/Markdown>`_ or `reStructuredText <http://en.wikipedia.org/wiki/ReStructuredText>`_).
If you want to impress your future boss with your resume, it's a must. It's a proof of seriousness to see that a student took the time to learn |vim| on his or her own. Moreover, you'll have a unique tool to write all what you'll have to write (and that you'll be able to use for the rest of your career): your LaTeX reports, your slideshows, your code (if you need Word or LibreOffice to write you reports, it's time to use `LaTeX <http://en.wikipedia.org/wiki/LaTeX>`_, `Markdown <http://en.wikipedia.org/wiki/Markdown>`_ or `reStructuredText <http://en.wikipedia.org/wiki/ReStructuredText>`_).

Friendly advice: for your slideshows, don't hesitate to use something like `impress.js <http://bartaz.github.com/impress.js>`_. It's using HTML/JS/CSS and I highly recommend that you use it to do awesome presentations based on non-proprietary technologies. You can have a look at `reveal.js <http://lab.hakim.se/reveal-js/>`_ too, and its online editor `slide.es <http://slid.es/>`_.

**Teacher**
It's time to set an example for your students and to teach them a tool they will use during their entire life. A lot more than any other programming language.
It's time to set an example for your students and to teach them a tool they will use during their entire life. |Vim| is something they'll be able to use a lot more than any programming language.

**Coder**
To invest time in your daily tool is something essential. You'll anyway have to learn keyboard shortcuts, so you'd better do it for something useful. If this investment is still profitable 10 years from now, it's the perfect investment, it's |vim|.
It's essential to invest time in your daily tool. You'll be learning keyboard shortcuts anyway, so you should do it for something useful. If this investment is still profitable 10 years from now, it's the perfect investment. If you put time into learning |vim|, you will be able to use it for many decades.

**System and network administrator**
If you use *Emacs*, then I can forgive you. If you use nano/pico, there is nothing I can do for you, otherwise, it's time to get some work done folks! To remotely administrate a Unix system is the perfect use case for |vim| (a powerful text editor without the need of a graphical interface).
If you use *Emacs*, then I can forgive you. If you use nano/pico, there is nothing I can do for you. Otherwise, it's time to get some work done, folks! Remote administration of a Unix system is the perfect use case for |vim| (a powerful text editor without the need of a graphical interface).

**Writer**
If you write using Markdown/reStructuredText/WikiMarkup or LaTeX, |vim| will save you a lot of time. You'll not be able to go back to another editor after it, or you'll want to *Vimify* it at all costs.
Expand All @@ -60,20 +60,20 @@ Trust me, I have done and still do all these 5 roles, and my best investment has
What you will be learning
=========================

- How to use |vim| as an "usual" editor first (you know, the type of text editors having syntax highlighting, allowing you to open files, to click using the mouse, …). In short, the demystification of |vim| that will allow you to go further.
- How to move from classical text edition to the power of |vim|, baby step by baby step (it's where addiction begins).
- How to use |vim| as a "usual" editor first (you know, the type of text editors having syntax highlighting, allowing you to open files, to click using the mouse, …). In short, we will be demystifying |vim| to allow you to go further.
- How to move from classical text editing to the power of |vim|, baby step by baby step (it's where addiction begins).
- How to do without the mouse and why it's the best thing that can happen to you when you're programming/writing text.
- How you can easily deduce keyboard shortcuts with some simple rules.

To sum up: as you consider yourself a craftsman, act like one. Learn how to use your tool, once and for all.
To sum up: if you consider yourself a craftsman, act like one. Learn how to use your tool, once and for all.

What you will not be learning
=============================

- You'll not be learning how to install and to configure |vim| for Windows. It's doable, but I have very limited knowledge about Windows. It may happen, but not yet. Only Linux/Unix will be discussed (and by extension Mac OS X).
- You'll not be learning how to use *Vi* (notice the lack of "*m*"). I'll only teach you how to be productive writing text with |vim|, I'll not teach you how to impress your friends with *Vi* (and anyway, |vim| is enough for that). For those who don't get what I'm talking about, *Vi* is the "ancestor of |vim| (which stands for *Vi* - *IMproved*)" and is installed by default on all Unix-like systems (even on Mac OS X).
- You'll not be learning to know |vim| by heart: this book is not a reference it's a pragmatic smart way to learn |vim|.
- You'll not learn how to pimp the colors of your |vim|: I'll use the `Solarized <http://ethanschoonover.com/solarized>`_ theme, it's the best theme for your eyes.
- You will not be learning how to install and to configure |vim| for Windows. It's doable, but I have very limited knowledge about Windows. It may happen, but not yet. Only Linux/Unix will be discussed (and by extension Mac OS X).
- You will not be learning how to use *Vi* (notice the lack of "*m*"). I'll only teach you how to be productive writing text with |vim|, I won't be teachng you how to impress your friends with *Vi* (and anyway, |vim| is enough for that). For those who don't get what I'm talking about, *Vi* is the "ancestor of |vim| (which stands for *Vi* - *IMproved*)" and is installed by default on all Unix-like systems (even on Mac OS X).
- You will not be learning to know |vim| by heart: this book is not a reference it's a pragmatic smart way to learn |vim|.
- You will not learn how to pimp the colors of your |vim|, although I will go over how to change your theme. I'll use the `Solarized <http://ethanschoonover.com/solarized>`_ theme, it's the best theme for your eyes.

The hardest part is to get started
==================================
Expand All @@ -83,8 +83,8 @@ So, your are ready for the adventure? Ready to sacrifice one hour to start using
With |vim| you'll have to struggle. No matter how big your willpower is, you will struggle. Be prepared. The goal of this guide is to diminish this struggle as much as possible, but be aware that you will struggle anyway. No pain, no gain. Here is the method I recommend to tame the beast:

- Try to make using |vim| a habit. Be sure to follow this guide until the chapter about *The NERD Tree* (the file explorer). Then you'll be able to use |vim| as you would do with Notepad++, Textmate or Sublime Text for example. You'll be using only 1% of the capacities of |vim|, but whatever. What really matters is to use |vim| on a daily basis.
- Be sure to have a printed sheet with all the main |vim| shortcuts near you. The goal here is not to learn them by heart, but only to have somewhere to look when you'll ask yourself: "it surely exists a better way to do this".
- Keep the faith. At the beginning you'll be sceptical regarding the usefulness of learning everything from scratch with |vim|. And then, one day, you'll have a "a ha!" moment. You'll be asking yourself why all the softwares your are using can't be controlled using |vim| shortcuts.
- Keep in mind that it's an investment for your next 20 years. And everybody knows that investment are rarely profitable immediately.
- Be sure to have a printed sheet with all the main |vim| shortcuts near you. The goal here is not to learn them by heart, but only to have somewhere to look when you'll ask yourself: "There must be a better way to do this".
- Keep the faith. At the beginning you'll be sceptical regarding the usefulness of learning everything from scratch with |vim|. And then, one day, you'll have that "a-ha!" moment. You'll be asking yourself why all the software you're using can't be controlled using |vim| shortcuts.
- Keep in mind that it's an investment for your next 20 years. As you know, investments are rarely profitable immediately.

So, enough talking, let's get started!
Loading