TASK: Raise content for 1.5 Hours

This commit is contained in:
Daniel Siepmann 2018-10-24 18:02:14 +02:00
parent 6d6775ebda
commit 9f6592b100
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 160 additions and 8 deletions

View file

@ -40,4 +40,13 @@ class LoremIpsum2 extends AnotherClass
{ {
return $this->loremIpsum->getSum(); return $this->loremIpsum->getSum();
} }
public function getSomeStuff(): array
{
return [
'key1' => 'value1'
'key2' => 'value2'
'key3' => 'value3'
];
}
} }

View file

@ -1,6 +1,10 @@
Vim introduction workshop Vim introduction workshop
========================= =========================
.. contents::
This information can be found at https://github.com/DanielSiepmann/vim-introduction-workshop
Welcome Welcome
------- -------
@ -26,8 +30,8 @@ Run `vim lorem-ipsum.md` and type `:set number` to activate line numbers.
If you quit Vim and re open the file, line numbers are gun. Settings adjusted within If you quit Vim and re open the file, line numbers are gun. Settings adjusted within
a session are not persisted. We get back to that later. a session are not persisted. We get back to that later.
The concepts The modes
------------ ---------
We now have the basics, let's learn some basic concepts. We now have the basics, let's learn some basic concepts.
@ -145,15 +149,18 @@ Vim has a huuuuge documentation on board. This can be accessed via `:help`.
The help consists of a guide, reference, topics and plugins. The help consists of a guide, reference, topics and plugins.
Code navigation Part 1 Code navigation
---------------------- ---------------
1 Motions
^^^^^^^^^
Let's check out `:help object-motions` to get further movements. Let's check out `:help object-motions` to get further movements.
TASK: `vim lorem-ipsum.php` and navigate to the 2nd method via `]]` TASK: `vim lorem-ipsum.php` and navigate to the 2nd method via `]]`
Code navigation Part 2 Plugins 2 Plugins
------------------------------ ^^^^^^^^^
There are a bunch of plugins and even some plugin manager to choose from. There are a bunch of plugins and even some plugin manager to choose from.
@ -163,8 +170,8 @@ To navigate within Code I use CTRLP and Tagbar in combination with Universal Cta
* TASK: Check out the benefits, run `nvim lorem-ipsum.php` and type in `,b`. * TASK: Check out the benefits, run `nvim lorem-ipsum.php` and type in `,b`.
Code navigation Part 3 Go to definition 3 Go to definition
--------------------------------------- ^^^^^^^^^^^^^^^^^^
Vim provides support for tags out of the box. Using `CTRL+]` we can jump to the Vim provides support for tags out of the box. Using `CTRL+]` we can jump to the
definition of something. definition of something.
@ -189,6 +196,142 @@ this can be combined with either a count as prefix, or a motion as suffix.
In our case we want to change text within `()` as this is the condition in PHP. We In our case we want to change text within `()` as this is the condition in PHP. We
can achieve this by typing `ci(` within the braces. can achieve this by typing `ci(` within the braces.
Editing remote files
--------------------
Vim implements different protocols and can open .gz or .zip files out of the box.
Also scp:// and other protocols are support. This way one can edit remote files from
local computer using his Vim.
To open a remote file type ``vim scp://daniel-siepmann.de/apps/staemme/allys.py``.
Or from within vim ``:e scp://daniel-siepmann.de/apps/staemme/allys.py``.
See ``:help scp``
Also you can open files under the cursor with system settings using ``gx``. To open a
file under cursor with vim use ``gf``.
TASK: Edit the file
https://tmp.daniel-siepmann.de/events/nca18/workshop-vim/example.html with vim.
Vimrc
-----
Vim will load specific files during startup and in specific circumstances. The main
file is ~/.vimrc on load. To persist settings, e.g. turned on line numbers, write
them down into the file.
Like shell scripts, the file consists of Vim commands. E.g. turning line numbers on
results in ``:set number``, so write ``set number`` to the file.
This way you can tune Vim to *YOUR* editor. You will not find two Vim users out there
with the same setup. Vim is always *YOUR* editor.
Completion
----------
Wait, an editor has completion? Yes, and Vim has a lot!
See: ``:help ins-completion`` It's a new mode! You can insert the mode inside the
insert mode by typing ``CTRL+x`` followed by the completion mode.
TASK: Insert the word "hello" right here, using completion:
TASK: Insert the filename "lorem-ipsum2.php" right here, using completion:
TASK: Insert this chapter name right here, using completion:
The registers
-------------
Vim comes with a lot of "clipboards". You have installed some fancy application for
that? No need inside Vim. Clipboards within Vim are called registers. And there are a
lot of them. Some are auto filled, some are up to you.
See ``:help registers`` You can copy stuff from within a file using ``"yyy`` or
``"ayy`` where ``"a`` and ``"y`` is the register to copy to and ``yy`` is the motion,
yank current line. As always, this can be combined with already known motions.
To paste from a register, use ``"yp`` where ``"y`` again is the register and ``p`` or
``P`` is the paste after or before.
TASK: Yank this line and add it to "The dot".
TASK: Yank the first paragraph of "The registers" and paste if after this sentence.
The dot
-------
Last time I didn't mention the "dot". Once you learn to make atomic operations within
Vim, the dot becomes a huge productivity increase. He will repeat the last atomic
operation, e.g. you insert a comma to the end of a line, you can repeat that.
TASK: Add a comma at the end of the first array entry within lorem-ipsum2.php and
repeat the change for the two following lines.
Macros
------
Some might already know macros from Microsoft Excel or other editors. Vim also comes
with editors. A single macro is just a recorded set of keystrokes which can be
re-played.
Each macro is saved into a register. Thus it can be saved, loaded and modified.
The change done within "The dot" section can be achieved using a macro.
To record a macro type ``qq`` where the first ``q`` starts the recording and the 2nd
``q`` defined the register.
To replay a macro type ``@q`` where ``@`` starts the playback and ``q`` is the
register. As most of the time you can prefix the playback with a count, e.g. ``2@q``
will repeat macro ``q`` two times.
TASK: Repeat the task from "The dot" using a macro.
Settings Part 2
---------------
We now should now all we need to work effectively with Vim. Still we didn't cover
settings very well. We know how to show line numbers and how to store settings. But
what kind of settings do we have, what can we achieve with settings?
Syntax highlighting
^^^^^^^^^^^^^^^^^^^
E.g. add the following to highlight hearts in red:
hi ERROR ctermfg=9
match ERROR /♥/
TASK: Highlight the word TYPO3 in orange.
Tip: Color code for orange is 214
See: ``:help hi`` ``:help match``
Autocommands
^^^^^^^^^^^^
You know events from Symfony, or signals / slots from TYPO3? You will love
autocommands in Vim.
See: ``:help autocommand``
Workflows
---------
Now some workflows from my daily work within Vim.
Linting
^^^^^^^
Executing tests
^^^^^^^^^^^^^^^
Rendering docs
^^^^^^^^^^^^^^
What's next? What's next?
------------ ------------