Reputation: 1495
I am making the switch to VIM from Textmate and I wanted to know what should be included in my .vimrc to get the similar behavior for:
<tab>
on for will generate a common 'for' useThanks.
Upvotes: 1
Views: 916
Reputation: 196596
The first thing to be aware is that you can't turn Vim into TextMate. The second, is that you shouldn't even try.
Instead, focus your efforts on learning Vim, progressively, and grow/shrink your collection of settings and plugins as you need. Using Janus or some other "distro" will only occult Vim behind other people's arbitrary choices.
That said,
"auto-close on brackets, paranthesis, etc."
can be done in a "dumb" way by adding this line to your ~/.vimrc
:
inoremap ( ()<Left>
inoremap
is for mapping in insert mode (note the i
)
(
is the key you want to press, that's your trigger
()<Left>
means input a pair of parenthesis then go back one character, between the parenthesis
If you need a "smarter" way, there are a many plugins to choose from.
You might want to try surround which was in and of itself a very compelling reason for me to switch from TextMate.
"when i open a bracket and select enter, the open bracket is on 1st line, the cursor on the 2nd line indented, and the closing bracket on the 3rd line"
can be done in many ways as well, for example:
inoremap <C-Return> <CR><CR><C-o>k<Tab>
inoremap
, again
<C-Return>
means Ctrl+Return
, that's your trigger
<CR><CR>
means 2 carriage returns to push the closing bracket 2 lines below
<C-o>
to leave insert mode only for one command
k
to go up one line
<Tab>
to put the insertion cursor at the right place
Mappings in Vim can be just that: shortcuts for sequences of keypresses or more serious scripts.
"pressing <Tab>
on for will generate a common 'for' use"
can be done with a dedicated plugin like SnipMate. There are others.
Upvotes: 11
Reputation: 14125
auto-close on brackets, paranthesis, etc.
There are a number of plugins for this functionality: autoclose, closepairs, simplepairs
auto tabbing after a bracket
By this, I believe you mean automatic indentation. This is a default Vim behavior when you're working on a supported filetype. If you're just starting on a file and haven't saved it, you can manually set the filetype with :set ft=<whatever filetype you want>
and you'll get indentation and syntax highlighting.
when i open a bracket and select enter, the open bracket is on 1st line, the cursor on the 2nd line indented, and the closing bracket on the 3rd line
This will be taken care of with the above auto-close plugins.
pressing tab on for will generate a common 'for' use
These are called "snippets" in TextMate. Snipmate is a commonly used Vim plugin for snippets. Other people prefer xptemplate.
If you're moving from TextMate to Vim, I would try installing Janus and thoroughly reading the documentation.
Janus is a great starter distribution of plugins and mappings for Vim, gVim, and MacVim. It features sane defaults and aims to provide a minimal working environment using the most popular plug-ins and the most common mappings. It was developed and is maintained by Carl Lerche and former TextMate user Yehuda Katz.
My own personal experience/advice is that you can really drive yourself crazy trying to mimic every feature of your favorite editor exactly as it was. Each feature you're trying to replicate is probably just a quirk you became used to through muscle memory. You'll be much more productive if you just start "accepting" Vim, learning it, and re-train your muscle memory for it.
Upvotes: 7