通常Vim的全局命令:g //以每行爲基礎工作。是否有可能使其按每個事件的基礎進行工作,因爲一行中可能有多個事件。如何製作Vim的全局命令:g /按每個事件處理
3
A
回答
0
不是一個直接的答案,但你可以使用類似於:rubydo,它將在每行代碼中運行一些ruby scriptlet。把它與紅寶石中的gsub結合起來應該讓你能夠在每次匹配時做任何事情。當然,你需要使用Ruby代碼來做到這一點,這可能不會讓你訪問,您可能需要毫不費力的一切(註冊追加將惱人的實例)
:[range]rubyd[o] {cmd} Evaluate Ruby command {cmd} for each line in the
[range], with $_ being set to the text of each line in
turn, without a trailing <EOL>. Setting $_ will change
the text, but note that it is not possible to add or
delete lines using this command.
The default for [range] is the whole file: "1,$".
0
你可以試試:
command! -bang -nargs=1 -range OGlobal
\ <line1>,<line2>call s:Global("<bang>", <f-args>)
function! s:Global(bang, param) range
let inverse = a:bang == '!'
" obtain the separator character
let sep = a:param[0]
" obtain all fields in the initial command
let fields = split(a:param, sep)
" todo: handle inverse
let l = a:firstline
while 1
let l = search(fields[0], 'W')
if l == -1 || l > a:lastline
break
endif
exe fields[1]
endwhile
endfunction
,你可以爲:global
使用,除了命令名稱是不同的(並且,由於尚未實現的爆炸選項)
相關問題
- 1. 如何按照動作命令處理mousepressed事件
- 2. Vim的份額Ex命令全局
- 3. vim:運行基於一個命令的多個命令:全局命令
- 4. C#事件處理命令
- 5. Node.js事件處理命令
- 6. 如何在匹配和行上使用Vim全局命令?
- 7. 全局錯誤/事件處理
- 8. VB.NET 2005 - 「全局」事件處理程序?
- 9. 如何使用此設置執行vim內部全局命令?
- 10. 如何編寫批處理文件來運行vim命令
- 11. 如何在Vim的g命令的標準模式下逃脫
- 12. 在vim中使用:g命令和多個動作
- 13. 如何讓Symfony命令全局運行
- 14. windows批處理/每行多個命令
- 15. WPF命令Click事件處理程序
- 16. Adobe Flex/Actionscript事件處理命令
- 17. 如何讓Vim處理我的命令後退?
- 18. 如何使用全局變量在事件處理程序
- 19. 爲什麼這個vim全局命令不能正確執行?
- 20. 全局控制TableAdapter命令超時
- 21. 每天使用批處理命令文件複製
- 22. 一次爲每個文件執行多個批處理命令
- 23. Unsuscribe事件的每個處理程序
- 24. 如何在Vim中以可視模式映射`g CTRL-G`命令?
- 25. 如何用gunzip命令處理這個
- 26. 如何在Silverlight中使用MVVM爲每個控件使用命令模式處理多個事件?
- 27. 如何在GIM的XML文件中使用VIM for Windows中的gg = G命令?
- 28. Vaadin處理佈局事件
- 29. Vim netrw複製命令
- 30. 作爲交易處理多個命令
回答這個問題需要有關vim的腳本知識。 AFAIK,SU不是關於編程 - 而答案需要編程技巧...... – 2010-06-02 11:30:23
@Don:即使這不需要腳本化解決方案(因爲功能不是內置的),這仍然是正確的放置它。 http://meta.stackexchange.com/questions/25925/vim-questions-so-or-su – Cascabel 2010-06-02 12:58:02
你需要在每一次事件中做什麼操作?爲什麼你需要一個在線操作的操作員? – 2010-06-02 14:54:37