Search code examples
htmlcsscvimcode-completion

Vim Shortcuts or plug-ins for the following


I have been using the Sublime editor and is making a switch to vim (Because I have to) . I have heard that Vim is the best editor there is, if you can master all the shortcuts. Given below are some of my needs. Please tell me which shortcut/plug-in I should use to achieve them.

  1. Switch-case statement in C : I need like 10 cases. So How can I add them quickly? Is there something like case n:10+ ?
  2. Curly Bracket completion : I need an auto closing curly bracket }. Same need with parenthesis.
  3. In CSS : Code completion for properties.
  4. Code shrink option : In Sublime u could shrink the code present in a block (like a function or loop) by pressing an > like symbol to the left of line number. Is this possible in Vim?
  5. Any other shortcut / plug-in that programmer ( C, C++, php, CSS, HTML ) can use to increase his/her productivity.

Any help is appreciated.


Solution

    1. Switch-case statement in C : I need like 10 cases. So How can I add them quickly? Is there something like case n:10+ ?

      ocase :<CR>break;<Esc>
      9.
      

      See :help repeating.

      Take a look at SnipMate or Ultisnips, though.

    2. Curly Bracket completion : I need an auto closing curly bracket }. Same need with parenthesis.

      That "feature" is not that useful but if you didn't already grow tired of it, you can find a good list on the Vim wiki..

    3. In CSS : Code completion for properties.

      It's built-in. Try <C-x><C-o> after a couple of characters. If you don't like the default <C-x><C-o>, create your own with:

      inoremap <key> <C-x><C-o>
      

      See :help key-mapping and :help key-notation.

    4. Code shrink option : In Sublime u could shrink the code present in a block (like a function or loop) by pressing an > like symbol to the left of line number. Is this possible in Vim?

      That feature is universally called "folding". You can close a fold with zc, open it with zo, toggle it with za and much more. See :help folding.

    5. Any other shortcut / plug-in that programmer ( C, C++, php, CSS, HTML ) can use to increase his/her productivity.

      Learn Vim before looking for plugins.