0

Sorry for a noob question, but i find it struggling to just put a ";" at the end of line after writing a function. For example, I am coding in C and many time i need to write things like:

f(a);

what i usually type is (from normal mode, using bracket autopair-like feature):

if(a<ESC><SHIFT-a>;

and it need changing mode twice! Comparing to normal editor (sublime):

f(a<right>;

does anyone have more efficient way do do those typing? thanks for any help.

vantubk
  • 5
  • 1
  • What is the reason you "must" change out of insert mode after typing `a`, and what bracket auto-pair-like feature are you using? – clarity123 Nov 26 '15 at 04:37
  • [delimate](https://github.com/Raimondi/delimitMate). and while using vim, I don't want to use arrow key to move in insert mode. Thus i must change to normal mode, move to end of line, come back to insert mode, then type ; .seems complicated, right? – vantubk Nov 26 '15 at 04:50

3 Answers3

1

If you're a vim user, you can hit Shift-a.

Shift-a takes you from normal mode to insert mode, and starts your cursor at the end of the line.

(If you want to be an efficient vim user, you should remap esc to something like caps-lock.)

hlin117
  • 20,764
  • 31
  • 72
  • 93
  • I already did all those thing (see my key sequence), but it still not as effective as sublime. – vantubk Nov 26 '15 at 04:43
  • Sorry, didn't know that you were specifying that you were coding in vim. Does it matter that much though? In the common case, vim is gonna be much faster. (And like I said, you should try avoiding using esc.) – hlin117 Nov 26 '15 at 05:41
  • agree, vim is much efficient in other cases. – vantubk Nov 26 '15 at 06:55
1

I think you have some "auto-close" plugin installed. I have that kind of plugin too, and I don't press arrow keys either, since I don't have them on my keyboard. I have this:

" moving cursor out of (right of ) autoClosed brackets
inoremap <c-l> <esc>%%a

So with your example: it would be (assume already in INSERT mode)

f(a<ctrl-l>;

Thus, your fingers never leave the home row.

Kent
  • 189,393
  • 32
  • 233
  • 301
  • I've never use any "auto-close" plugins. Are those plugins really useful? As seen in this question, it introduces cumbersome than convenience. BTW, I've seen some IDEs (Eclipse?) with "auto-close" feature in that [you could just type the right bracket (e.g. ")") as-is over the auto-inserted bracket](http://stackoverflow.com/a/14771283). // Anyhow, if I have nested brackets or complex bracket structures and later on decided to edit them in-place, those plugins always act being smart by inserting / leaving superfluous brackets at the right hand side. :( I've never seen one implemented correctly. – cychoi Aug 15 '16 at 09:39
  • @cychoi if a plugin useful, I think this itself is subjective question. E.g. personally I think airline, powerline , *line plugin not useful, multi-cursors plugin not useful either.. however some people look at those scripts in different point of views, and they think they are useful for them... If you want some extra func, and found a plugin, you have to try it by yourself, to see if it is really "useful" for you... – Kent Aug 15 '16 at 11:04
0

Comparing to normal editor (sublime):

f(a<right>;

Well… that's exactly how you would do it in Vim if you use Delimitmate or some other "autoclosing" plugin. Why do you insist on making things more complicated than they are?

Community
  • 1
  • 1
romainl
  • 186,200
  • 21
  • 280
  • 313