如何在Vim中对数字和文字列进行排序 [英] How to sort numeric and literal columns in Vim
本文介绍了如何在Vim中对数字和文字列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Vim 6.0.假设我正在编辑此文件:
Using Vim 6.0. Say I'm editing this file:
sdfsdg
dfgdfg
34 12
2 4
45 1
34 5
如何对第二列进行排序?
How do I sort the second column?
推荐答案
如果有合适的外壳,请选择数字并运行命令
If you have decent shell available, select your numbers and run the command
:'<,'>!sort -n -k 2
如果要在可视模式下键入此内容,则在键入冒号之后,标记<"会自动出现,而您只需要键入其余部分即可.
If you gonna type this in visual mode, after typing the colon, markers '<,'> will appead automatically, and you'll only have to type the rest of it.
这种类型的命令(:[motion]!)被称为过滤.您可以通过咨询vim的帮助来了解更多信息:
This type of commands (:[motion]!) is called filtering. You can learn more by consulting vim's help:
:h filter
这篇关于如何在Vim中对数字和文字列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文