Thursday, January 14, 2021

Too many lines when pasting into vim.

Sometimes you're pasting into vim on a remote console and it puts in an extra newline.

apiVersion: v1

kind: ConfigMap

metadata:

  namespace: metallb-system
  
  name: config
  
data:

  config: |
  
    address-pools:
    
    - name: default
    
      protocol: layer2
      
      addresses:
      
      - 192.168.1.240-192.168.1.250
      

Well that's an ugly bummer. Here's a quick fix, do a replace all...


:%s/\n\n/\r/g

This effectively says,

:%s/\n\n/\r/g

For each line, globally substitute two newlines with a newline.

Result:

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.1.240-192.168.1.250

No comments:

Post a Comment