vim备忘

2014/07/01 16:41
阅读数 116

以指定编码打开文件原文

<!-- lang: shell -->
vim file.txt -c "e ++enc=GB18030" 
e ++enc=GB18030 

保存root权限的文件

  1. vi /etc/httpd.conf 保存时,用命令:w !sudo tee % :w - Write a file. !sudo - Call shell sudo command. tee - The output of write (vim :w) command is redirected using tee. The % is nothing but current file name i.e. /etc/httpd.conf. In other words tee command is run as root and it takes standard input and write it to a file represented by %. However, this will prompt to reload file again (hit L to load changes in vim itself). 强烈推荐这一种用法。不过,首先得保证运行vim的用户有sudo的权限。

转自:这里 在《vim实用技巧》中也提到了这种方法。不过当时对*nix的命令理解不深,以为tee是一个用户名……汗~


重新载入文件原文

1 重新载入当前文件: :e :e! #放弃当前修改,强制重新载入 2 重新载入所有打开的文件: :bufdo e 或者 :bufdo :e! :bufdo命令表示把后面的命令应用到所有buffer中的文件。


#查找(不区分大小写) 查找字符+\c。其中\c可以出现在任意位置。如需要不区分大小写查找“abc”或“AbC”:

<!-- lang: shell -->
/abc\c
/\cabc
/a\cbc

编辑远程文件

示例为:scp://[user@]host/path 无论用scp 还是ftp、sftp, 如果打开有问题,可以试着在帮助中所谓的host和path之间再加一个“/”试试。 如:vim scp://root@172.24.181.70//enosoft/pushserv/a.txt 而在shell中直接使用scp要在host和path之间加一个“:”呵呵~

展开阅读全文
vim
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部