As you say, that's a good way to force your fingers to learn the way of h, j, k and l.
I started with vi so long ago that I remember being surprised around five years ago when I accidentally discovered that vim knows about the arrow keys. So I've never had to un-learn the arrow keys.
You may want to turn them back on eventually. It's nice to be able to move the cursor without thinking about it, whether your hands are on the keyboard, over the arrow keys or on the mouse, sort of like being able to play the chord you want no matter where your hand is on the fretboard.
As for my .vimrc, there are years of settings and commands I never use and can't remember what for, like junk DNA. I enjoy discovering and sharing the occasional treat, but I've gone pretty much meat and potatoes over the years.
Depending on your setup, your ruler (:set ruler) may or may not always show the file. This will make it always show:
set statusline=%<%F\ %h%m%r%=%-14.(%l,%c%V%)\ %P
I like the tabula colorscheme, which you can find on vim.org:
colorscheme tabula
I like smartcase:
set ic
set smartcase
and I like the ability to override it when I search:
/\Cfindonlylowercaseinstances
(:help, and then look in chapter usr_27.txt)
Downvoting seems to be in fashion lately. I've noticed a lot of perfectly good comments voted down without any apparent cause, only to float back up later on.
This is something of the last two weeks or so, before that it was happening too, but much less frequently.
Could it have something to do with the mechanism for voting and the prevalence of iPhones? I think it would be the cats meow if when detecting the iPhone or any mobile browser the down vote arrow was moved to the right of the title bar area. I say this because my fat fingered attempt at upvoting a comment has the reverse effect of my intent on many occasion.
PG, Are you still looking for a specific iPhone interface?
Me too, I've done this on occasion on my iPhone. The arrows are so small and close together. If you see capitalized words in the middle of a sentence Like this, that too is the iPhone's fault.
I've been using Vim for over ten years now, across several jobs and platforms and tasks, so my .vimrc and .gvimrc have gathered quite a bit of cruft. I keep them in a git repository along with my various other generically useful config files, and just check them out on each new machine I get an account on.
There's too much stuff in these files to describe what everything does, but there's a lot of comments, so along with the Vim online help you should be able to figure everything out:
Highlights include a single key-binding for stepping through every buffer in every tab, consistent mouse-handling between console-vim and gvim, and code to automatically make gvim inherit the GNOME default monospace font.
colors torte
syn on
set expandtab
set tabstop=4
set shiftwidth=4
set ruler
set ignorecase
set autoindent
set smartindent
set hlsearch
set incsearch
set backspace=indent,eol,start
set laststatus=2
autocmd BufEnter * :syntax sync fromstart
"set hidden
set history=1000
runtime macros/matchit.vim
set wildmenu
"set wildmode=list:longest
set wildmode=longest:full,full
set title
set scrolloff=3
autocmd BufEnter *.rb :set ts=2 sw=2
"let c_space_errors=1
I'm kinda unsure what good posting this will do...
This crap has accumulated over the years, so I'm not sure if any of it is obsolete or unneeded, but here's what I found in mine:
set expandtab " Convert tabs to spaces
set tabstop=4 " <TAB> four spaces
set shiftwidth=4 " Shift width four spaces (for auto indent)
set noautoindent " Turn off autoindent by default
set smartindent " Use smart indent instead
set incsearch " Use incremental searches (cool)
set backspace=2 " Set backspace mode to allow backspacing in insert mode
set ruler " Show position of cursor in status line
set showmatch " Show matching parens/braces when writing code
set wh=55 " Minimum window height
set textwidth=78 " Maximum line width when writing comments
" Speed up response to ESC key
set notimeout
set ttimeout
set timeoutlen=100
" Make completion more like bash
set wildmode=longest,list
" Cure hangs during compiles?
set swapsync=
" For fuck's sake, don't throw away the indent when i hit #
inoremap # X^H#
" Disable auto-commenting of // in C/C++
au FileType c,cpp setlocal comments-=://
" Highlight trailing whitespace
hi TrailingSpace ctermbg=1
au filetype c,cpp,python match TrailingSpace "\s\+\n"
I work on many different systems from time to time. I don't like to get too used to things that aren't universal. I have found out (the hard way) that relying on convenience can bite you in the ass when it's 3AM and you've been up for 67 consecutive hours and you execute some keystrokes from habit and they don't do what you expected.
I'll admit, I probably cripple my productivity overall for working this way, but it's what I'm used to.
> I have found out (the hard way) that relying on convenience can bite you in the ass when it's 3AM and you've been up for 67 consecutive hours and you execute some keystrokes from habit and they don't do what you expected.
You really could say that about anything. You could say that one shouldn't program in dynamically-typed languages because 'one day' you'll have to program in a statically-typed language and all your habits will 'bite you in the ass.' I think that you should really blame this part:
> and you've been up for 67 consecutive hours
Unless you're trying out for the SEALS, I don't think this is normally part of any job description. And I hardly think this is some sort of 'common case' that you should be planning for. There's a difference between preparing for the worst and over-preparing for the worst.
Don't get me wrong, there are many conveniences that I DO use.
However, for editors I've just always preferred to stay as basic and reliable as possible. vi is quick, easy, simple and has been on every *nix machine that I've ever walked up to. Relying on customizitions beyond that is, for me, sub-optimal.
I have had more than a handful of workdays that spanned 2 or 3 or 4 continuous days with little or no sleep at all (although thankfully not in several years). In those cases we were usually recovering from planned maintenance gone wrong. In one case I was trying to edit/update some config files, force software upgrades into a bunch core switches and dispatch pilots with spare parts. It was helpful, to me, to be able to rely on the basics as I hopped through SSH sessions from server to server (but, I did use host keys to speed my logins).
My case is moreso for edits and small customizations and not long sessions of coding, so I really don't NEED a whole lot beyond the basics of what I can memorize.
set statusline=[TYPE=%Y]\ [ENC=%{&fenc}]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]
hi StatusLine term=bold,reverse cterm=bold ctermfg=7 ctermbg=0
hi StatusLineNC term=reverse cterm=bold ctermfg=8
gives me a nice status bar with some good info
set t_Co=256
colorscheme railscasts
best color scheme I've found yet, and I don't know how I lived before 256 colors
set noerrorbells
set novisualbell
set t_vb=
This might be redundant, but I hate error bells SO MUCH. This might be even more important than "set nocompatible".
map ^P :set paste!<CR>:set paste?<CR>
in python mode at least, autoindent will usually mess up pasted text
Plus the usual 4 space soft tab, autoindent stuff. I also highly suggest keeping your dotfiles in some kind of version control. It is definitely fun to see them grow, and I can't imagine working on multiple systems without it.
Mainly for python scripting, but works decently for most editing I do.
syntax on " syntax highlighting
set tabstop=4 " PEP-8 uses 4 spaces per indentation level
set shiftwidth=4 " shifting (PEP-8)
set expandtab " spaces instead of tabs (PEP-8, and just bettter in general)
filetype on " file type detection
filetype indent on " special indentation rules for file type
filetype plugin on " auto-completion rules for file type
set hls " highlight search terms (:noh to turn off temporarily)
set ignorecase " ignore case for searches (:set noignorecase to turn off)
set incsearch " search as you type
colorscheme darkblue " slightly nicer colour scheme
set scrolloff=15 " keep 15 lines of context on both sides of cursor when scrolling
" Keep cycled-away buffers open (preserving undo,
" allowing buffer switch without write)
set hidden
" Facilities for handling pasting into vim, preserving
" indentation of the pasted text.
" This will make <F4> start paste mode and <F5> stop paste mode.
" Note that typing <F5> in paste mode inserts <F5>, since in paste
" mode everything is inserted literally, except the 'pastetoggle' key
" sequence.
map <F4> :set paste<CR>
map <F5> :set nopaste<CR>
imap <F4> <C-O>:set paste<CR>
imap <F5> <nop>
set pastetoggle=<F11>
" Toggle line-numbers with key sequence Ctrl-N-N:
nmap <C-N><C-N> :set invnumber <CR>
" Consolidate swapfiles to keep working directories clean
set directory=~/.vim/swap
Been through some changes lately - this is the trimmed down of my .gvimrc (MacVim).
" window settings
set lines=70
set columns=200
set fileencoding=utf8
set incsearch
set ignorecase
set hlsearch
" make the status line more useful
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
set nocompatible
" backspace mode
set bs=2
" highlitt current line and add line numbers
set cursorline
set number
" yummy
set guifont=Monaco:h11.00
" turn off the scrollbars and the rest of the crap
set guioptions=eg
""set foldenable
""set foldmethod=indent
filetype plugin on
filetype on
" autoindenting
set cindent
set smartindent
set autoindent
" display improvements
set list
" show indents
set listchars=tab:\.\ ,trail:-
set ruler
set showcmd
" i use tabs instead of spaces, wanna make something of it?
set noexpandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
" temp files
set backupdir=~/.vim/bak
set directory=~/.vim/tmp
" colorz
syntax on
colorscheme herald " molokai, zenburn, darkburn, vibrantink
" PLUGINZ
" allml settings
let g:allml_global_maps = 1
let g:HiMtchBrkt=1
let g:SCMDiffCommand="/opt/subversion/bin/svn"
inoremap <C-B> <ESC>:call PhpDocSingle()<CR>
nnoremap <C-B> :call PhpDocSingle()<CR>
vnoremap <C-B> :call PhpDocRange()<CR>
" PHP specific fixes
" highlights interpolated variables in sql strings and does sql-syntax highlighting. yay
autocmd FileType php let php_sql_query=1
" does exactly that. highlights html inside of php strings
autocmd FileType php let php_htmlInStrings=1
" discourages use oh short tags. c'mon its deprecated remember
autocmd FileType php let php_noShortTags=1
" settings for cake
au BufNewFile *.ctp set filetype=php
au BufRead *.ctp set filetype=php
:set et sts=4 sw=4 ts=4
et = expandtab (spaces instead of tabs)
ts = tabstop (the number of spaces that a tab equates to)
sw = shiftwidth (the number of spaces to use when indenting
-- or de-indenting -- a line)
sts = softtabstop (the number of spaces to use when expanding tabs)
Also you might want to move 'colorscheme twilight' into the ~/.gvimrc file instead; it makes the .vimrc file cleaner when you separated out all of the gui-specific stuff.
Here are just a couple things I find really useful day to day. I used to have a timeout that would revert to normal mode from insert mode after about 30 seconds if idle, but I got tired of that after about six months and just got in the habit of hitting Escape when I finished with an insert action. I did it just now, even though this is a textarea.
" For (ab)use with :sp
map <C-j> <C-W>j<C-W>_
map <C-k> <C-W>k<C-W>_
set wmh=0 so=999 winheight=999
nnoremap i :noh<CR>i
" \s is global-replace-this-word
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>
Most of my .vim folder and .vimrc came from andreiz and tomasr. I have it committed to github for easy download on any server I'm working on. http://github.com/bnmrrs/dotfies if anybody would like to check it out.
let mapleader = "," "
let g:mapleader = ","
map <Leader>q :q!<CR>
map <Leader>s :w<CR>
map <Leader>w :x<CR>
The mapleader is basically used to give your custom keybindings a separate namespace. It looks like that's what your doing here, but using the variable makes it easier to change later f you want.
I think :set wildmenu is great, especially for relative newbies such as myself:
command! CD cd %:p:h " change to current buffer's directory
set incsearch " Incremental search
set hlsearch " Highlight search
set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
set nowritebackup " no stupid backup files
set noswapfile " no stupid recovery files
set wildmenu " it's wild
set visualbell
set fileformat=unix
"tab completion of words in insert mode
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
And to answer the poster, I tend to just use the default vim. I'm bouncing around machines so much that I don't bother setting anything up on my main one that I'll miss on the others...
Going into an old codebase and just running ':set list' with just the default listchars is maddening enough. The mixes of tabs and whitespace characters is enough to drive one batty. Especially when you find files where someone was using tabs, but with the 'ts=8' or 'ts=2' rather than 'ts=4'.
" for vertical split, with the pipe dividers hidden
:hi clear vertsplit
:hi vertsplit ctermbg=Black ctermfg=Black
" quit quits all
:nmap :q :qa
:nmap :wq :wqa
" H/L go to beginning/end of line without moving fingers
:nmap H 0
:nmap L $
" turn off matching paren highlighting
let loaded_matchparen = 1
Sorry about how long this is!! This is the culmination of about 1.5 years using VIM as my exclusive text editor for web development. When I started I was using PHP and now I'm using Ruby on Rails. If you have any general questions about VIM, specific questions about my .vimrc, or anything related, ask in the comments and I'll try to answer:
set fo=tcqln ic nohls nu sc scs sm tm=200 wim=longest,list nonumber
let g:explDetailedList=1
" store all of your vim swp files in one place, make sure this directory exists
set backupdir=/Users/{YOUR_USERNAME}/vim_swp
set directory=/Users/{YOUR_USERNAME}/vim_swp
set bs=indent,eol,start
set hlsearch
" Use incremental searching
set incsearch
" Set standard setting for PEAR coding standards
set tabstop=4
set shiftwidth=4
" Auto expand tabs to spaces
set expandtab
" Auto indent after a {
set autoindent
set smartindent
" Linewidth to endless
set textwidth=0
" Do not wrap lines automatically
set wrap
" DO NOT Show line numbers by default
set nonumber
" Jump 5 lines when running out of the screen
set scrolljump=5
" Indicate jump out of the screen when 3 lines before end of the screen
set scrolloff=3
" Repair wired terminal/vim settings
set backspace=start,eol
" This function determines, wether we are on the start of the line text (then tab indents) or
" if we want to try autocompletion
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
" Remap the tab key to select action with InsertTabWrapper
" menu for encoding
set wildmenu
set wcm=<Tab>
set ts=4
menu Encoding.koi8-r :e ++enc=koi8-r<CR>
menu Encoding.windows-1251 :e ++enc=cp1251<CR>
menu Encoding.utf-8 :e ++enc=utf-8 <CR>
map <F8> :emenu Encoding.<TAB>
If you need something specific try http://vim.wikia.com/