Skip to content

Instantly share code, notes, and snippets.

@tyru
Forked from Dubhead/searchOpenParen.vim
Created November 24, 2010 09:39
Show Gist options
  • Select an option

  • Save tyru/713406 to your computer and use it in GitHub Desktop.

Select an option

Save tyru/713406 to your computer and use it in GitHub Desktop.
nnoremap <silent> ) :<C-u>call search("\\((\\|\\[\\|{\\|<\\|縲圭\|縲蚕\)\\zs")<CR>
nnoremap <silent> ( :<C-u>call search("\\((\\|\\[\\|{\\|<\\|縲圭\|縲蚕\)\\zs", 'b')<CR>
@tyru
Copy link
Author

tyru commented Nov 24, 2010

なんかgist.vimで読み込んだ時点で文字化けてた。ふーむ。

@Dubhead
Copy link

Dubhead commented Nov 24, 2010

添削きたー。感謝です。

@Dubhead
Copy link

Dubhead commented Nov 24, 2010

~/.vimrc 中に書く場合は、orのバックスラッシュは4つですね。クウォートややこしいです (-.-;

@tyru
Copy link
Author

tyru commented Nov 24, 2010

いや、2つでいいです。
.vimrcでも~/.vim/plugin/searchOpenParen.vimでも変わりません。

ただ、シングルクオートだと、バックスラッシュをエスケープせずにいけます。
シングルクオートの中でシングルクオートを表すには

echo 'foo''bar'

と2つ「'」を重ねます。
微妙に他の言語と違っててややこしいですね...

文字化けたので元のパターンを持ってくると、
シングルクオートで書きなおすと

search('\((\|\[\|{\|<\|「\|『\)\zs')
search('\((\|\[\|{\|<\|「\|『\)\zs', 'b')

こんな感じです。
自分は正規表現書くときはシングルクオート使ってます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment