Useful commands for CKA/CKAD/CKS exams
Command | Description |
---|---|
Shift + A | go to the end of the current row (insert mode) |
Shift + C | delete everything after the cursor (insert mode) |
Shift + I | go to the first letter on the current row (insert mode) |
Shift + G | go to the last row of data in the file |
Ctrl + O | Go back to lines |
Ctrl + I | Go forward |
Ctrl + D | Commands completion |
/search | Find stuff |
* | Search for other instances of the same word/char |
. | Repeat last executed command |
e | jump to the end of the next word |
w | jump to the start of the next word |
:40 | Goto line in the file |
wd | Delete word |
d$ | Delete from cursor |
3dd | Delete 3 lines |
v, V | Select, Select block |
r, R | Replace single char, replace from cursor |
o, O | Open a new line below o and above O the cursor |
dG | Delete from the cursor to the end of file |
gg | Go to the first-line |
gf | Go to fule under cursor |
g;, g, | Go to previous or next edit place in the file respectively first-line |
G | Got to the last line |
u | Undo, revert |
:%s/old/new/g | replace old with new in whole file |
_ (underscore) | Get to the first non-blank character of current line |
:! command | ENTER execute any command |
:e filename | Open another file |
: ls | List all open files |
:b # | Swap to file where # is file number |
:w name | save the current file under certain name |
:r filename | place content of a file where the cursor is positioned |
:% s/old_text/new_text/g | Execution mode, replace all old_text with new_text throughput file |
copy: yg_
paste: vg_p
Should also work with +
copy: "*y
paste: "*p
The black hole register "_ will do the trick, but there is a better solution:
When you enter the line back with the p command you are pasting the contents of the (volatile) default register "", which has been overwritten by dd. But you still can paste from the (non volatile) yank register "0, which won't be overwritten by the delete command dd.
So these are the commands you want to use as per your example:
yy
dd
"0p
Edit vim config file and set:
- line numbers, this is helpful when kubeclt detects an error on a specific line of the file
- tabs to spaces, use tab to set YAML indentation, it will be converted to spaces
vim ~/.vimrc
- create vim config file
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab