Control-^ってやったら、
日本語入力のON、OFFを切り替えられる事に気づいた。 そうか、そうだったんだ。
全然知らなかったよ。 ちなみに、ノーマルモードで、
Control-^ってやると、こっちは代替ファイルとの切り替えになります。
たぶん、直前に開いていたファイルが開かれることになるかな。
Control-^ってやったら、
Control-^ってやると、こっちは代替ファイルとの切り替えになります。
:help local-additionsとか、実行すると、確認できる。
:helptags $HOME/vimfiles/docdocディレクトリにファイルが無い場合は、エラーが発生してしまうけれど、これは気にしなくていい。
:if exists('loaded_undobranch_viewer') :finish :endif :let loaded_undobranch_viewer = 1 :command! -nargs=0 UndoBranchViewer :call s:UndoBranchViewer() :function! s:UndoBranchViewer() :let g:undolistHandlers = [ \ {'key': 16, 'agent': s:SNR().'AgentUndoPreview', 'key_name': '<c-p>', 'help': 'Undo preview'}, \ {'pick_last_item': 0}, \ ] :let s:undolists = tlib#cmd#OutputAsList('undolist') :call tlib#input#List('s', 'UndoBranch', s:undolists, g:undolistHandlers) :endfunction :function! s:AgentUndoPreview(world, selected) :return a:world :endfunction :function! s:SNR() :return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSNR$') :endfunction finish ============================================================== スクリプトのコメントとか、 履歴とか記述。「finish」と書いて、そこでスクリプトの読み込みを停止、
ウィンドウを分割して、片方のウィンドウに何かのリストを表示、選択されたら何かの処理を行うという、
ファイルエクスプローラーとかでよくあるUIを、簡単に構築できてしまうvimスクリプト tlibの使い方を突き止めた。
(vimスクリプト組む人以外には、役に立たない情報ですが)
で、下が最小のサンプル。
:UndoBranchViewerで起動して、<C-p>で選択した行のメッセージを表示する。
動かすには、もちろん、tlibが必要。
tlib#input#List()に表示する文字列のリストと、
どのキーが押されたら、どのファンクションを呼び出すかのマッピングを渡す。
keyがリストの選択に使うキーで、agentがファンクション。
スクリプトの中で使っている tlib#cmd#OutputAsList()は、
コマンドの結果で文字列のリストを作るコマンドです。
" スクリプトが何度も読まれるのを防止するためのおまじない :if exists('loaded_undobranch_viewer') :finish :endif :let loaded_undobranch_viewer = 1 " コマンドの定義 " :UndoBranchViewerってすると、s:UndoBranchViewer()が呼び出される。 :command! -nargs=0 UndoBranchViewer :call s:UndoBranchViewer() :function! s:UndoBranchViewer() :let g:undolistHandlers = [ \ {'key': 16, 'agent': s:SNR().'AgentUndoPreview', 'key_name': '<c-p>', 'help': 'Undo preview'}, \ {'key': 21, 'agent': s:SNR().'AgentUndoAndClose', 'key_name': '<c-u>', 'help': 'Undo and close'}, \ {'pick_last_item': 0}, \ ] :let s:undolists = tlib#cmd#OutputAsList('undolist') :call tlib#input#List('s', 'UndoBranch', s:undolists, g:undolistHandlers) :endfunction " リストから<c-p>で選択されたときに呼び出される。 :function! s:AgentUndoPreview(world, selected) :let l:entry = a:selected[0] " 選択された文字を表示。 :echo l:entry " 文字を表示できるように、ちょっと待ってもらう。 :5sleep :return a:world :endfunction " リストから<c-u>で選択されたときに呼び出される。 " 説明は省略 :function! s:AgentUndoAndClose(world, selected) :return a:world :endfunction " tlibのリストでどれが選択されたかを特定するための文字を返す :function! s:SNR() :return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSNR$') :endfunction
E97
:help E97
*E97*
Vim will do a test if the diff output looks alright. If it doesn't, you will
get an error message. Possible causes:
- The "diff" program cannot be executed.
- The "diff" program doesn't produce normal "ed" style diffs (see above).
- The 'shell' and associated options are not set correctly. Try if filtering
works with a command like ":!sort".
- You are using 'diffexpr' and it doesn't work.
If it's not clear what the problem is set the 'verbose' option to one or more
to see more messages.
The self-installing Vim includes a diff program. If you don't have it you
might want to download a diff.exe. For example from
http://jlb.twu.net/code/unixkit.php.
:help エラーのコード
gf
カーソルをファイル名の上に置いて"gf"と入力すると、
カーソル下に書いてあるファイル名のファイルを開ける。
開こうとしているファイルは"with space text.txt"だが、
"with"というファイルを開こうとしてエラーになる。
visualモードでファイル名を選択してからなら、
スペース入りファイル名でも、gfコマンドでファイルを開くことはできる。
:set isfname+=32
設定を行う。
":set isfname+=32"と設定した後は、
スペースがファイル名に入っていても、gfコマンドで開けるようになった。
:helpgrep search_keyword
"helpgrep"コマンドの検索では、
検索がヒットしすぎてしまうこともある。
上は":helpgrep"コマンドで"register"を検索したら、
沢山見つかりすぎてしまったの図。
:helpgrep search_keyword
:copenで、grep結果の一覧を表示、
:ccloseで、一覧を閉じることができます。
grep結果一覧からファイルを選択すると、
そのドキュメントをvimエディタで開ける。
:help visual.txt | /Visual-block Insert
Visual-block Insert
With a blockwise selection, I{string}<ESC> will
insert {string} at the start
of block on every line of the block.
vimエディタで矩形選択して、「I」を入力して入力モードに移った後、
文字列{string}を入力、
その後、<ESC>を押すと、矩形選択した全ての行のブロックの先頭に、
先ほど入力した文字列{string}が入力されます。
Visual-block Append
With a blockwise selection, A{string}<ESC> will
append {string} to the end of
block on every line of the block.
vimエディタで矩形選択して、「A」を入力して入力モードに移った後、
文字列{string}を入力、
その後、<ESC>を押すと、矩形選択した全ての行のブロックの最後に、
先ほど入力した文字列{string}が入力されます。
insert into card_info values ('NW0001', 'ALFKI');
insert into card_info values ('NW0002', 'ALFKI');
insert into card_info values ('NW0003', 'ALFKI');
insert into card_info values ('NW0004', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0001', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0002', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0003', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0004', 'ALFKI');
insert into card_info values ('NW0001', 'ALFKI');
insert into card_info values ('NW0002', 'ALFKI');
insert into card_info values ('NW0003', 'ALFKI');
insert into card_info values ('NW0004', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0001', 'ALFKI');
insert into card_info values ('NW0002', 'ALFKI');
insert into card_info values ('NW0003', 'ALFKI');
insert into card_info values ('NW0004', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0001', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0002', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0003', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0004', 'ALFKI');
insert into card_info values ('NW0001', 'ALFKI');
insert into card_info values ('NW0002', 'ALFKI');
insert into card_info values ('NW0003', 'ALFKI');
insert into card_info values ('NW0004', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0001', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0002', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0003', 'ALFKI');
insert into card_info (card_id, customer_id) values ('NW0004', 'ALFKI');
:'<,'>s/\%23c次に「%c」でテキストを差し込むカラム位置を指定、
:'<,'>s/\%23c/(card_id, customer_id) /差し込むテキストを入力して実行。
:e
Ctrl-x
カレントディレクトリは$HOMEで、
編集中のファイルは"/usr/local/include/readline/rltypedefs.h"です。
このCtrl-xの機能はKaoriya版の機能です。
:CdCurrentコマンドはKaoriya版の機能です。
:set notitleと設定しておくと、
:set title 設定の時
:set notitle 設定の時
augroup vimrcEx
au BufRead * if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" | endif
augroup END
上の設定を追加する。
:source $VIMRUNTIME/vimrc_example.vim
ただし、後者の方法(方法2)は、vimrc_example.vimの他の設定も追加されてしまう。
" 例.ファイルを保存して終了。「:wq」と同じ。
:w | :q
" 例.置換を実行してから保存。
:%s/pre/post/g | :w
:bufdo :%s/previous/replaced/gc | :w
:bufdoは、vimエディタで開いている全バッファに対して、
続くコマンドを実行します。
:bufdo :%s/previous/replaced/gcで良いのですけど。
:wa
:w >> file_path
ファイル保存ダイアログとは、
メニューの「名前を付けて保存(A)」を選択した時に表示される、このダイアログのこと。
:set browsedir=bufferと設定すれば、編集中のファイルのあるディレクトリが
:set browsedir=currentと設定すれば、カレントディレクトリが
:set browsedir=/path/to/default/directory
:set browsedir=last
詳しくはvimエディタを立ち上げて、
「:help browsedir」を入力して表示される、ヘルプを見てください。
<C-r> /と入力すると呼び出せるので、これを使う。
関連
vimエディタの「レジスタ」第4話
http://advweb.seesaa.net/article/517151.html
検索に使用した文字は「/」のレジスタに入る。
:%s/
<C-r> /
この広告は90日以上新しい記事の投稿がないブログに表示されております。