Vim smart insert semicolon

vim semicolon movement
vim add comma to end of every line
vi semicolon
vim-surround
vim radical
vim insert at end of line

Is there a Vim plugin that can handle smart semicolon insertion, like the one in Eclipse?

Example (pipe character is insertion cursor):

foobar(|)

I type a semicolon:

foobar();|

Similarly:

foobar("blah|")

I type a semicolon:

foobar("blah");|

If I want a semicolon at the original cursor position, I press backspace after the smart re-position:

foobar("hello|")
foobar("hello");|
foobar("hello;|")

Vim smart insert semicolon, I use this mapping: inoremap <leader>; <C-o>A;. It's not ; because I use semicolons often and in more than one context. <C-o> is used to input� Smart semi-colon in Emacs (and Vim). GitHub Gist: instantly share code, notes, and snippets.

I want to do the same thing, I works on it whole night, tons of code, but at last, I got a simple solution.

inoremap ;<cr> <end>;<cr>

and if I am in a brace, I want to add a semicolon or a dot at the end, like this

foo({
  |
})

I press ;;<cr> or ..<cr> to do this

inoremap ;<cr> <end>;<cr>
inoremap .<cr> <end>.
inoremap ;;<cr> <down><end>;<cr>
inoremap ..<cr> <down><end>.

lfilho/cosco.vim: VIM colon and semicolon insertion bliss, Contribute to lfilho/cosco.vim development by creating an account on GitHub. By default what triggers the auto insertion is leaving insert mode ( InsertLeave� VIM colon and semicolon insertion bliss. Contribute to lfilho/cosco.vim development by creating an account on GitHub.

You should try Cosco.vim plugin.

Vim smart insert semicolon - vim - html, Is there a Vim plugin that can handle smart semicolon insertion, like the one in Eclipse? Example (pipe character is insertion cursor): foobar(|) I type a semicolon :� Shift+Enter Insert semicolon at the end of line and continue on the same line. Alt+Enter Insert semicolon at the end of line and continue on the new line. Ctrl+Alt+Enter Insert semicolon and stay at the same position

I use the following function and a mapping to insert a semicolon to the end of the line and to delete the remaning spaces:

imap <leader>. <C-R>=Semicolonfun()<CR>
fun! Semicolonfun() "{{{
  call setline(line('.'), substitute(getline('.'), '\s*$', ';', ''))
  return "\<End>"
endfunction "}}}

So if you have something like:

log.warning("you miss the |identifier")

Pressing . or ,. if you remap the leader, you get the following:

log.warning("you miss the identifier");|

Vim smart insert semicolon, Is there a Vim plugin that can handle smart semicolon insertion, like the one in Eclipse? Example (pipe character is insertion cursor): foobar(|). I type a semicolon� It switches the input method to the default keyboard (usually English) when leaving insert mode and switches back when you enter insert mode again. It consists of 2 tiny programs: im-select: a command-line utility to get/set active input method; smartim.vim: a vim plugin to do automatic input method switch, using im-select; It is Mac-only for now.

inoremap <expr> ;<cr> getline('.')[-1:] == ';' ? '\<Nop>' : '<End>;<CR>'

The code above will check if there is ; at the end of the line.

If ; not exists, then it will add ; otherwise do nothing.

Speed up your already speedy Vim development (Example), A protip by chrismckinnel about vim and productivity. As an added bonus to doing this, you can disable Vims auto-save feature if you haven't end with ; , why not remap ;; to append a ; to the end of the line, save the file and exit insert mode? xmodmap -e "keycode 47 = colon semicolon Cyrillic_ZHE" All these commands can be followed by ; (semicolon) to go to the next searched item, and , (comma) to go the previous searched item; Insert/Appending/Editing Text. Results in Insert mode i - start insert mode at cursor; I - insert at the beginning of the line; a - append after the cursor; A - append at the end of the line

Smart Semicolon, Automatic Line Change. Auto Line Change Basic. When enabled, this extension automatically inserts a new line below the current cursor and put� vim tips and tricks indenting. Some variables you might want to set: :set tabstop=8 - tabs are at proper location :set expandtab - don't use actual tab character (ctrl-v) :set shiftwidth=4 - indenting is 4 spaces :set autoindent - turns it on :set smartindent - does the right thing (mostly) in programs :set cindent - stricter rules for C programs

insert.txt, Special keys ins-special-keys In Insert and Replace mode, the following characters have a Insert the contents of a register literally and don't auto-indent . This is a comma separated list of items: item action indent allow backspacing over� One of the general tenants of vim is to not navigate in insert mode. It's common to map caps lock to ESC to make it easier to exit insert mode. Another general vim tenant is to be in insert mode as little as possible. – Matt Greer Jan 5 '12 at 21:22

Custom Autoclose Mappings. Extra tip: source external files into , Some Vim users goes straight to install some plugins like auto pairs or autoclose Autoclose adding comma ( , ) or semicolon ( ; ) in the end movements on insert mode (I also added this mappings on the end of this article).

Comments
  • And what if you want to actually have a semicolon inside your string literal?
  • In Eclipse pressing backspace after a smart semicolon insert will put the semicolon in the original cursor position.
  • The ideal solution: use Python. Then you don't need to worry about semicolons ;-)
  • @ChrisMorgan For my poor brain, switching between Python and Java/C++/JavaScript is somewhat like switching between Mac and Windows. I can do basically the same things in the same way, but with enough devilish differences to give me a migraine.
  • @dansomething: Oh yes! Since that answer, I've modified that line many times in my ~/.vimrc. Here is the current incarnation: inoremap <leader>; <C-o>m`<C-o>A;<C-o>``
  • With your mapping, vim waits for a second character on each <leader> key press.
  • @Koshimitsu this is standard behavior and you notice it only if you pause yourself.
  • @TARDISMaker, I don't have that mapping anymore. Are you talking about the one in my comment? <C-o> leaves insert mode for a single command. m` creates a context mark. <C-o> again. A; appends a semicolon at the end of the line. <C-o> again. And finally `` to jump back to the mark we set earlier.
  • Frankly id rather use something that wont trip up insert mode, like a function key (which ill never remember) or a ctrl shortcut