Use the kubectl patch command to edit a ConfigMap resource. This approach is non-interactive and is useful when you need to script the changes to a resource:
kubectl patch configmap/myconf --patch '{"data": {"key1":"newvalue1"}}'
You can also edit a secret resource using the kubectl patch command:
kubectl patch secret/mysecret --patch '{"data":{"password":"bmV3cGFzc3dvcmQK"}}'