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;|")
command.” A; add the semicolon at end of line, so we can run: :'<,'>normal A; to add semicolon at endline of selected. :%normal A; to add semicolon at endline of entire file.
To avoid the extra 'shift' keypress when typing the colon to go to cmdline mode, I mapped the semicolon key to do the same thing. This overwrites the original mapping of repeating the last f or t command.
Press ctrl-; or ctrl+, to add/remove a semicolon at the end of the selected lines.
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 a single normal mode command.A;
means "add a ;
at the end of the line".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>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With