如何在多个缓冲区/选项卡上运行命令以删除尾随空格? [英] How to run command over multiple buffers/tabs to remove trailing spaces?

查看:29
本文介绍了如何在多个缓冲区/选项卡上运行命令以删除尾随空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个命令可以在 vim 中整理代码中过多的空白:

I have a command to tidy up excessive whitespace in my code in vim:

" to tidy excess whitespace
map <leader>1 :execute ':%s#\s\+$##g'<CR>

我的问题是,如果我打开了 10 个选项卡或缓冲区,我如何才能将此命令应用于所有选项卡或缓冲区,而不仅仅是逐个应用该命令.

My question is, if I have 10 tabs or buffers open, how can I apply this command to all of them, rather than just going to each one and applying the command.

推荐答案

参见这个 vim 使用 bufdo 的提示,窗口和标签.

假设您的所有缓冲区都在缓冲区列表中,那么您的地图可能很简单

Assuming all your buffers are in the buffer list, your map could be as simple as

" to tidy excess whitespace
map <leader>1 :execute ':bufdo! %s#\s\+$##g'<CR>

这篇关于如何在多个缓冲区/选项卡上运行命令以删除尾随空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆