From 00a31329c4c6e5eb49ce824ebe1ef5cf534c284d Mon Sep 17 00:00:00 2001 From: Luiz Gonzaga dos Santos Filho Date: Sat, 6 Apr 2013 23:53:49 +0200 Subject: [PATCH] Improving semicolon insertion at the end of the line --- vim/plugin/settings/yadr-append-semicolon.vim | 13 +++++++++++++ vim/plugin/settings/yadr-keymap.vim | 3 --- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 vim/plugin/settings/yadr-append-semicolon.vim diff --git a/vim/plugin/settings/yadr-append-semicolon.vim b/vim/plugin/settings/yadr-append-semicolon.vim new file mode 100644 index 0000000..50a0a2a --- /dev/null +++ b/vim/plugin/settings/yadr-append-semicolon.vim @@ -0,0 +1,13 @@ +" If there isn't one, append a semi colon to the end of the current line. +function! s:appendSemiColon() + if getline('.') !~ ';$' + let original_cursor_position = getpos('.') + exec("s/$/;/") + call setpos('.', original_cursor_position) + endif +endfunction + +" For programming languages using a semi colon at the end of statement. +autocmd FileType c,cpp,css,java,javascript,perl,php,jade nmap ;; :call appendSemiColon() +autocmd FileType c,cpp,css,java,javascript,perl,php,jade inoremap ;; :call appendSemiColon()a + diff --git a/vim/plugin/settings/yadr-keymap.vim b/vim/plugin/settings/yadr-keymap.vim index ed6f853..e0a5043 100644 --- a/vim/plugin/settings/yadr-keymap.vim +++ b/vim/plugin/settings/yadr-keymap.vim @@ -65,9 +65,6 @@ vmap ,{ c{"} " gary bernhardt's hashrocket imap => -" Semicolon at end of line by typing ;; -inoremap ;; A; - " Change inside various enclosures with Cmd-" and Cmd-' " The f makes it find the enclosure so you don't have " to be standing inside it