---
title: "vim 相关"
author: "cherishLC"
date: "2018-03-22T15:29:11Z"
tags: ["vim"]
categories: ["非技术"]
slug: "vim"
draft: false
lastmod: "2018-05-14T17:25:46Z"
id: 2324558
url: "https://cherishlc.iteye.com/blog/2324558"
---

<span style="color:blue">1、中文显示乱码</span>
在~/.vimrc 文件中，加入以下内容：

> set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
>    set termencoding=utf-8
>    set encoding=utf-8

参考自：<http://www.cnblogs.com/joeyupdo/archive/2013/03/03/2941737.html>


<span style="color:blue">2、保存readonly的文件</span>

```vim
:w !sudo tee %
```

<https://stackoverflow.com/questions/28635647/how-can-i-save-a-file-i-opened-in-vim-as-the-wrong-user>