2022-06-25 11:40:05 +02:00
|
|
|
---
|
|
|
|
title: Vim
|
2022-11-19 15:25:20 +01:00
|
|
|
visible: true
|
2022-06-25 11:40:05 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
[toc]
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-06-25 11:40:05 +02:00
|
|
|
## Get output from command
|
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
`:r!(command)`
|
|
|
|
|
|
|
|
_Example to get UUID for a disk_
|
|
|
|
`:r!blkid /dev/(partition) -sUUID -ovalue`
|
2022-06-25 11:40:05 +02:00
|
|
|
|
|
|
|
## Write as sudo user
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
`:w !sudo tee %`
|
2022-06-25 11:40:05 +02:00
|
|
|
|
|
|
|
## Replace strings
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-06-25 11:40:05 +02:00
|
|
|
Globally replace strings
|
2023-02-23 14:48:51 +01:00
|
|
|
`:%s/foo/bar/g`
|
2022-06-25 11:40:05 +02:00
|
|
|
|
|
|
|
Replace strings in line 6 to 10
|
2023-02-23 14:48:51 +01:00
|
|
|
`:6,10s/foo/bar/g`
|