Academic off season
- Retreat 2024
- Time for reflection and learning new skills for next season
- What is worth investing time in? 🤔
- One skill to influence everything:
- Academia == Glorified text editing
Text editing
- Usual text editing:
- Movement: mouse & arrow keys
- Editing: backspace, delete, shift+click, copy, paste
- Cons:
- Hands don’t stay on home row
- Inefficient & slow (compared to alternative)
- Exists a more efficient way of editing text:
Vim
- Vim, an old obscure text editor?
- A toolbox to edit text efficiently
- Available in editors (Vim bindings)
- E.g. VSCode, JupyterLab, Overleaf
- Rest of presentation think:
- Vim == toolbox for efficient text editing
Setup for rest of presentation
- Left side: Vim concepts with text
- Right side: short video of the concepts applied
- Bottom: keys pressed in real time
- PechaKucha is only a teaser
- Ressources for further learning in the end
- 30 min.
vimtutor
highly encouraged
Vim: multi-modal text editing
- One mode for each task
- Normal Mode:
- Quick editing and navigation
- Insert Mode
- What you are used to (+more)
- Visual Mode
- For selecting text and editing it fast
- \(+\) More modes left out for brievity
Basic movements in normal mode
h
, j
, k
, l
- Move left, down, up, right
w
, b
,
- Move by words (forward/backward)
0
, $
- Jump to the beginning/end of a line
- Home row all the time
More movements in normal mode
Ctrl-d
, Ctrl-u
- Scroll down/up half a page
gg
, G
- Jump to the beginning/end of the file
Ctrl-o
, Ctrl-i
- Jump to the previous/next cursor position
Deleting words
- Vim has several operators for editing text
d
- Delete operator (normal mode)
dw
- delete word
d2w
- delete two words
diw
- delete word under cursor
Changing words
c
- Change operator (normal mode)
cw
- change word (and enter insert mode)
c2w
- change two words
ciw
- change word under cursor
Change everything inside delimiters
- Using
c
, the change operator:
ci(
- change everything inside parentheses
ci[
- change everything inside brackets
ci{
- change everything inside curly braces
- Can stand anywhere inside delimiters and change it!
Change everything inside quotes
- Using
c
, the change operator:
ci"
- change everything inside double quotes
ci'
- change everything inside single quotes
- Can stand anywhere on line and change it!
Changing surrounding delimiters/quotes
- Using
cs
, the change surrounding operator:
cs"'
- change surrounding double quotes to single quotes
cs])
- change surrounding brackets to parentheses
cs})
- change surrounding curly braces to parentheses
Deleting surrounding delimiters/quotes
- Using
ds
, the delete surrounding operator:
ds"
- delete surrounding double quotes
ds)
- delete surrounding parentheses
ds}
- delete surrounding curly braces
Inserting new line above and below
o
- insert new line below the current line
O
- insert new line above the current line
- Correct indentation is kept
Front, back, join
I
- insert at the beginning of the line
A
- insert at the end of the line
J
- join the current line with the next line
Substitutions
:s/foo/bar/g
- substitute
foo
with bar
on current line
:%s/ipsum/lorem/g
- substitute
ipsum
with lorem
in entire file
- Can use regular expressions (regex)
- Regex practice suddenly very useful!
Substitutions on selected lines
- Edit selected lines:
- Select lines in visual mode
- Write substitution command
- Quickly edit multiple lines at once
- Example:
- Convert list of names to strings at once
&
means whatever matched in first part
Marks
- Marks are like bookmarks
- Jump between different parts of file
ma
set a mark with the name a
mb
set a mark with the name b
'a
jump to the mark a
'b
jump to the mark b
Takeaways
- Vim
- An editor
- A toolbox for efficient text editing
- Vim bindings available in many editors
- Fixed cost of learning, afterwards:
- You will be able to edit text (much) faster
- Text editing in general becomes fun
- Does not matter what text you edit; it is fun just to edit text
- Have only scratched the tip of the iceberg
- So much good stuff left out!
Ressources for further learning
Appendix (not in PechaKucha)
- Use the American keyboard layout when coding
- Delimiters, braces & square brackets, much more comfortable
- Maps
Caps Lock
-> Escape
and Escape
-> Caps Lock
Caps Lock
is rarely used; Escape
is used all the time
- Use the 10 finger method