Last active
January 26, 2018 00:03
-
-
Save suzusime/7569521491018e094a3e292981f6d640 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if exists('b:did_ftplugin_tex_flag') | |
finish | |
endif | |
let b:did_ftplugin_tex_flag = 1 | |
scriptencoding utf-8 | |
" 数式用のキーマップに設定する函数 | |
:function! s:SetKeyMap() | |
:ino <buffer> B@ B | |
:ino <buffer> B<Space> B<Space> | |
" :ino <buffer> <expr> B "\\bm{" . nr2char(getchar()) . "}" . "<Left>" | |
:ino <buffer> B \bm{}<Left> | |
:ino <buffer> Gb \beta | |
:endfunction | |
" 普通のキーマップに戻す函数 | |
:function! s:UnSetKeyMap() | |
:silent! iu <buffer> B@ | |
:silent! iu <buffer> B<Space> | |
:silent! iu <buffer> B | |
:silent! iu <buffer> Gb | |
:endfunction | |
" キーマップの設定を手動で実行するコマンド | |
:command -buffer Math :call s:SetKeyMap() | |
:command -buffer UnMath :call s:UnSetKeyMap() | |
" 数式入力モードで挿入モードに入る | |
:nn <buffer> <Leader>mi :Math<CR>i | |
" 挿入モードから抜けるときに自動で普通のキーマップに戻す | |
" <Esc>に割り当ててしまうと矢印キー等がつかえなくなるので<C-C>を使う | |
" :ino <buffer> <silent> <unique> <C-C> <C-C>:UnMath<CR> | |
" 次のようにすればよい(但しこの場合<C-C>では呼ばれない) | |
:au InsertLeave <buffer> UnMath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment