求!!!使用vi如何倒序单词

Z___P 2012-08-03 12:03:02
使用vi可以进行 行倒序

123
456
789
变为
789
456
123

但是如何对单词进行倒序,如在shell脚本开发中
case
变为
esac

请指教,谢谢!
...全文
257 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ForestDB 2012-08-03
  • 打赏
  • 举报
回复
我一般是这么输入的:
左手打case,右手操作“向左”,左手一下,右手一下。
iEverX 2012-08-03
  • 打赏
  • 举报
回复
可以在.vimrc中加上这么一句
abbr rcase esac
然后敲rcase就好了。。
c87527124 2012-08-03
  • 打赏
  • 举报
回复
我看看vim和emacs会不会掐起来
lucky-lucky 2012-08-03
  • 打赏
  • 举报
回复
要是在Linux下可以这样

:.!rev

使用rev命令可以反转字符串,点号是选中当前行的意思,可以使用n1,n2指定当前行
赵4老师 2012-08-03
  • 打赏
  • 举报
回复
strrev
V____ 2012-08-03
  • 打赏
  • 举报
回复
没有现成的,参考用@定义个,再用
Z___P 2012-08-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

我一般是这么输入的:
左手打case,右手操作“向左”,左手一下,右手一下。
[/Quote]

左右互搏~~
CandPointer 2012-08-03
  • 打赏
  • 举报
回复
换用 Emacs 吧。
轻松解决。 如果某些 奇特功能,emacs 没有现成的。 可以自己写。

Emacs + Lisp = 春暖花开


--------
ReverseWords

The command ‘M-x reverse-region’ will reverse the lines a region. To get the word-based reversal use the command by EvaluatingExpressions or by adding to your InitFile:

(defun reverse-words (beg end)
"Reverse the order of words in region."
(interactive "r")
(apply
'insert
(reverse
(split-string
(delete-and-extract-region beg end) "\\b"))))

Example:

first, second, third - last.

Running ‘M-x reverse-words’ on this sentence with the region starting from the beginning but not including the period:

last - third, second, first.

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧