2007-09-16
C-aで、インデント文字を飛ばした行頭に戻りたい!
|追記。
それM-mで http://subtech.g.hatena.ne....
no title
おー、やっぱ元からあったのかー!あざーっす。
M-m runs the command back-to-indentation which is an interactive compiled Lisp function in `simple.el'. It is bound to M-m. (back-to-indentation) Move point to the first non-whitespace character on this line.
というわけで、インデントを飛ばした行頭に戻る場合には、back-to-indentationを使うようにした。
すでにあったりするかもしれないけど、練習のためやってみた。たとえばプログラムとか書いてて、C-aで行頭に戻る場合、ほんとの行頭じゃなくて、インデント文字を飛ばした行頭に戻りたいということが多い気がする。
if ($cond) { $foo->bar; # ↑ここに戻りたい }
そこで、以下のような関数を作ってみた。現在のポイント位置以前にインデント文字しかなければ、普通に行頭に戻り、他の文字が含まれていれば、インデント文字を飛ばした行頭に戻る。試しに、C-aに割り当ててみた。使ってて不都合があったら、あとで適当なものに変えるつもり。
(global-set-key "\C-a" 'beggining-of-indented-line) (defun beggining-of-indented-line (current-point) "インデント文字を飛ばした行頭に戻る。ただし、ポイントから行頭ま での間にインデント文字しかない場合は、行頭に戻る。" (interactive "d") (if (string-match "^[ \t]*$" (save-excursion (buffer-substring-no-properties (progn (beginning-of-line) (point)) current-point))) (beginning-of-line) (back-to-indentation)))
Valter2012/02/24 02:06An ientlliegnt point of view, well expressed! Thanks!
qouvds2012/02/25 03:18biFonY <a href="http://quefiigubgwl.com/">quefiigubgwl</a>
rjszcad2012/02/26 00:0866yimA , [url=http://ihkxuectdtiz.com/]ihkxuectdtiz[/url], [link=http://rcgeppctnzem.com/]rcgeppctnzem[/link], http://bnzoihkybcsb.com/
ckchcbio2012/03/01 02:18QQNRZE <a href="http://vurpaguxtjnw.com/">vurpaguxtjnw</a>
cluysxnhcna2012/03/13 15:13FmfdZH , [url=http://dynsurwlqpqq.com/]dynsurwlqpqq[/url], [link=http://uxvfouvsjqul.com/]uxvfouvsjqul[/link], http://atdkvbendsrm.com/