PTT Editor 板看到的問題:如何搜尋多行文字? 能不能 Visual 選起來搜尋?
以前從 kana 的 vimrc 看到一個自訂函數 search_the_selected_text_literaly('n')
,這個設計是在 Visual mode 打 * 便能尋找選取的文字。
封存
PTT Editor 板看到的問題:如何搜尋多行文字? 能不能 Visual 選起來搜尋?
以前從 kana 的 vimrc 看到一個自訂函數 search_the_selected_text_literaly('n')
,這個設計是在 Visual mode 打 * 便能尋找選取的文字。
剛剛發現,處理一下換行字元就能支援多行 pattern 了,具體為
substitute(pattern, '\V\n', '\\n', 'g')
。
" Ref: kana - https://github.com/kana/config vnoremap * :<C-U>set hlsearch<CR>:call <SID>search_selected_text_literaly('n')<CR> vnoremap # :<C-U>set hlsearch<CR>:call <SID>search_selected_text_literaly('N')<CR> function! s:search_selected_text_literaly(search_command) call SaveReg('0') call SaveReg('"') normal! gvy let pattern = escape(@0, '\') let pattern = substitute(pattern, '\V\n', '\\n', 'g') let @/ = pattern call histadd('/', '\V' . pattern) execute 'normal!' a:search_command let v:searchforward = a:search_command ==# 'n' call RestoreReg('0') call RestoreReg('"') endfunction
註:SaveReg
和 RestoreReg
是用來備份 register 的自訂函數,此處不重要,就不寫了。
多台電腦 git repository 最簡單的同步方式,應該是把 .git 目錄放在 Dropbox 底下。
在 repository 直接編輯 .git/config,加進一個叫做 {dropbox} 的 remote,url 設成 Dropbox 下的目錄;
再配合該 remote 設定一個叫 {wip} 的 branch。(後面有範例)
然後 cd 到 {dropbox} 目錄,把剛設的 remote url 建立起來:
git init --bare
日後只要在 {wip} branch 做 git pull
、push
就都是對 Dropbox 動作了。
我在 GitHub fork 別人專案後,通常會建一個 [remote "dropbox"]
,配合 [branch "wip"]
自己亂改。
寫到一個段落再整理進 master,另外 upstream branch 則是用來跟原作者的進度。
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git@github.com:{ME}/{PROJECT}.git [remote "upstream"] fetch = +refs/heads/*:refs/remotes/upstream/* url = git://github.com/{AUTHOR}/{PROJECT}.git [remote "dropbox"] fetch = +refs/heads/*:refs/remotes/dropbox/* url = /home/bootleq/dropbox/repository/bare/{PROJECT}/ [branch "master"] remote = origin merge = refs/heads/master [branch "upstream"] remote = upstream merge = refs/heads/master [branch "wip"] remote = dropbox merge = refs/heads/wip ; vim: filetype=gitconfig
在爸爸公司發現一本「客語字典」,查到一個阿婆常用、我一直不會寫的詞。
使用時機跟「屁咧」差不多,
大概也猜得到,應該是河洛話 de facto 寫法「豪洨」的那個詞。
但是這本字典只有兩個字「虛假」解釋,沒了。
國語典「漦」ㄌㄧˊ:
龍或魚的唾液。
龍所吐沫,龍之精氣也
。
相當實用,也許能取代「屁啦」。
以下是 2008 年發神經錄的,前三檔是我阿婆、最後一檔是我的聲音。
有了
mattn/wwwrenderer-vim
應該就能輕鬆「在 Vim 裡查字典」了吧?
這兩週諸事不順,寫了 3 個解法,只有一個堪用。
第一版的 function, 採用行動版 Google 字典(桌面版 8 月就關了),快又聰明,還能翻譯整句。
12/7 寫完,12/8 這個字典就停止服務、沒有中文了。 恨啊。
第二版的 function, 改用 Dr.eye(譯典通)字典行動版。
因為不是每次都慢,所以寫完→使用時才正視問題。 加入計時功能後,發現 query 常常要花上 10、甚至超過 30 秒,完全無法忍受。
明明 Firefox 開都蠻快的啊…… 總之我很灰心,不想查了。
第三次,不想再直接改舊 function,那個沒結構的東西寫了新的就失去舊的,太心寒了。
這次投靠微軟的
Bing 字典(智能手机版)
寫成
thinca/vim-ref 用的 source:
bootleq/vim-ref-bingzh - GitHub
成品還在不穩定階段,最近也無心重構,就是頂著用用。
目前顯示格式大致如圖,隨著每天使用,還會大改。
「必应词典」這個服務只有簡體字,以致: 1) 繁體的詞查不到翻譯, 2) 簡體的內文,台灣人看得很累。
解法是嘗試用 OpenCC 轉換,只要能執行 opencc
就自動轉。
目前我自己在 Ubuntu 上使用順利,不過 Windows 上還沒搞定。
nnoremap <silent> K :call ref#jump('normal', 'bingzh')<CR>
按 K 就會查游標上的單字。 目前 ref-bingzh 會自動把 CamelCase 或 under_score 拆開,只查其中一個字。
xnoremap <silent> K :call ref#jump('visual', 'bingzh')<CR>
在 visual mode 按 K 就會查選中的字。
cnoreabbrev <expr> k ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'Ref bingzh' : 'k')
打 :k<space>
會自動展開成 :Ref bingzh
方便輸入。
例如想查 foo 就打 :k<space>foo<Enter>。
神奇的解法!
取得BlogId >> data:blog.blogId
不妙,我也沒留底了
大大
檔案已失聯,跪求檔案
Yeah it really works but its better to keep a towel or any kind of cloth below the stained cloth nor the stain will be absorbed by the other side of that cloth.And it really doesn't matter whether the stain is of 1 week or 1 month.
Alec is awesome! I fix nearly everything that I possibly can in my home and use youtube almost exclusively. Most posts are a constant ramble and yammering and words filling dead air space. It 's unnecessary and confusing. Alec speaks only when necessary and demonstrates each fix quickly and accurately. Camera person is completely tuned in to every move Alec makes. Thanks! Just spot on