0

Possible Duplicate:
What is in your .vimrc?

I am fairly confident with vim having used it on and off for the past 3 years but I keep finding new simple suggestions for my vimrc for general editing which, after I use them seem blatantly obvious.

An example being:

noremap p "+p
noremap y "+y

For OS clipboard use (on my linux box anyway)

Another example being:

imap jj <ESC>

So in an attempt to collect together a definitive set of simple vimrc entries I will ask the questions, which do you find most useful?

Edit:

I am looking for the most basic vim commands, not functions and stringed commands

Community
  • 1
  • 1
rogermushroom
  • 5,486
  • 4
  • 42
  • 68
  • http://stackoverflow.com/questions/164847/what-is-in-your-vimrc – Marco Mariani Apr 05 '11 at 15:50
  • I want simple commands, that question centers around more complex multi command functions etc.. – rogermushroom Apr 05 '11 at 16:00
  • 1
    I strongly feel that this is a duplicate, however if this must stay open it needs to be a community wiki as there is no correct answer. – Randy Morris Apr 05 '11 at 16:08
  • what do the noremap examples do? – Vijay Dev Apr 05 '11 at 17:13
  • copies to the OS clipboard and pastes back, actually I have started using ,p and ,y for this so it's not intrusive on other vim clipboard functions – rogermushroom Apr 05 '11 at 17:19
  • @Vijay Dev: the first one pastes from the system clipboard and the second one copies to it. Useful if you're copy-pasting from/to different applications. This will work only if you have `+xterm_clipboard` in `:version`. Else, you'll have to re-compile with this option. – abcd Apr 05 '11 at 17:21
  • I already know about p and y being paste and yank. My question was with the "+p and "+y mappings. Sorry if I wasnt clear earlier – Vijay Dev Apr 05 '11 at 18:56
  • @Vijay: please read what both of us had written... using the `+` copies it to the **system clipboard** (which is a special buffer in vim) and not vim's default buffer. – abcd Apr 05 '11 at 19:11
  • Ahh! I must have been sleeping while I read your earlier answers!! Sorry about that :) – Vijay Dev Apr 05 '11 at 21:04
  • no problem :). With that shortcut and `iTerm2` for mac, I can easily move between vim and an IDE in split windows and copy pasta from one to another. Pretty useful. – abcd Apr 06 '11 at 02:57
  • @Jeff Atwood - For the record I disagree with this statement, I am unable to find a question that covers 'exactly' the same ground. The only link I have been provided (by Marco Mariani) specifically states an interest in Macros for c#, I state general simple editing commands, I think there is a big difference between the 2 – rogermushroom Apr 06 '11 at 15:08

1 Answers1

1

This will save you a lot of pinky strain over the years

nnoremap ; :

This remaps ; to :, as it is a relatively unused key and you don't have to press shift for the :. The : still works, just in case you still press shift from muscle memory.

Personally, I've also found these to be helpful:

1) Use first person shooter (FPS) games' movement keys for window movements (not a good idea if you use A or D often. I don't.)

map <W> <C-w><Up>
map <S> <C-w><Down>
map <A> <C-w><Left>
map <D> <C-w><Right>

2) Use <space> as a leader

nnoremap <space> <Nop>
let mapleader = " "

3) Disable middle mouse, especially on a mac, where inadvertently using the mouse (to switch applications) pastes content if middle click is accidentally pressed

map <MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>

4) Movement between tabs (kind of similar to Firefox)

map <T> :tabnew<Space>
map <Q> :tabclose<cr>
map <Leader>[ gT
map <Leader>] gt

I forgot to add that for the above, I use it as T <filename><enter>, which is a nice and quick way of opening a file in the current directory in a new tab.

abcd
  • 41,765
  • 7
  • 81
  • 98