Skip to content

Instantly share code, notes, and snippets.

@clicube
Created August 22, 2014 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clicube/4afd27b3af567a70fd2f to your computer and use it in GitHub Desktop.
Save clicube/4afd27b3af567a70fd2f to your computer and use it in GitHub Desktop.
Vim: Enterキー押下時、カーソルの右がとじ括弧だったら括弧の外側で改行
"----------------
" Enterキー押下時、カーソルの右がとじ括弧だったら括弧の外側で改行
"----------------
function! MyEnterFunc()
let pos = getpos('.')
let c = getline('.')[pos[2]-1]
if(c =~ "[\\)\\]]")
return "\<Right>\<Enter>"
endif
return "\<Enter>"
endfunction
inoremap <expr> <Enter> MyEnterFunc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment