Skip to content

Instantly share code, notes, and snippets.

@abelmartin
Created December 8, 2011 18:15
Show Gist options
  • Save abelmartin/1447901 to your computer and use it in GitHub Desktop.
Save abelmartin/1447901 to your computer and use it in GitHub Desktop.
VIMRC: Insert a carriage return without entering insert mode
let mapleader=","
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set nobackup
set nowritebackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set scrolloff=3
set cursorline " highlight current line
set hidden " allow unsaved buffers
" smart indent options
" set cindent
set smartindent
" Color scheme
colorscheme vividchalk
highlight NonText guibg=#060606
highlight Folded guibg=#0A0A0A guifg=#9090D0
set guifont=Monaco:h12
" Numbers
set number
set numberwidth=5
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set expandtab
" Always display the status line
set laststatus=2
" use w!! to sudo :w a file that we opened without su privs
cmap w!! w !sudo tee % >/dev/null
" Nerd Tree shortcut
map <leader>n :NERDTreeToggle<CR>
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Map a shortcut for rotating windows around
" Learned from Reddit: http://www.reddit.com/r/vim/comments/e6aw9/rotate_all_the_visible_windows_no_cwr/
map <leader>rr <C-w>K<C-W>r<C-W>k<C-W>H
" For Pathogen
call pathogen#runtime_append_all_bundles()
" Maintaining the visual line selection after indenting with '>' or '<'
vmap > >gv
vmap < <gv
" Enable JSLint plugin
filetype plugin on
" Autoc-compile coffee script
autocmd BufWritePost *.coffee silent CoffeeMake!
" Insert a carrage return exactly where you are and moves to the start of that line. The opposite of <Shift + j>
map <leader>j i<CR><ESC>^
" Insert a carrage return exactly where you are and moves to the start of that line. The opposite of <Shift + j>
" The "^" at the end ensure you're on the first character of the new line.
" Especially handy for the moments when vim is auto-indenting for you.
map <leader>j i<CR><ESC>^
@jonstorer
Copy link

All I've needed is i<CR><ESC> no leader or j

@abelmartin
Copy link
Author

Right, but I wanted a shortcut instead of typing all of those keys every time I wanted to do that. I was wondering if there's something like <Shift + j> that could be used instead. Otherwise I'll stick my mapping.

@jonstorer
Copy link

my bad, I missed the intent of you question. So far, nothing I know of. Googling suggests mapping something, so I'm guessing that's the way. I use h,j,k,l to navigate, so I'm out of luck there

@abelmartin
Copy link
Author

It's all good. That's the reason I use <leader>j. This way I can keep my navigation keys, but use the leader for extra stuff. I have other mappings in my .vimrc that do similar convenient things. You've got to pimp out your .vimrc man :)

@jonstorer
Copy link

jonstorer commented Dec 8, 2011 via email

@abelmartin
Copy link
Author

That's what I'm saying. Your current .vimrc file is pretty bare. I've added mine to this gist so you can see it in action. You've got a ton of plugins and things, but you've got to start pimping the vimrc file :)

@jonstorer
Copy link

jonstorer commented Dec 8, 2011 via email

@abelmartin
Copy link
Author

I see, you've got 2 files that combine to change your vim settings at runtime instead of just using a single file. As much as you like VIM now, you'll really love it when you start adding your own mappings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment