Live data from Hacker News

Ask HN: What's in your .vimrc file?

news.ycombinator.com

31–40 of 69 posts

Re: Ask HN: What's in your .vimrc file?

#31
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 "\"

    else

        return "\"

    endif
endfunction

" Remap the tab key to select action with InsertTabWrapper

inoremap =InsertTabWrapper()

" set list

" set listchars=tab:>-,trail:-

" set listchars=tab:>-,trail:-,eol:$

set ignorecase " caseinsensitive searches

set showmode " always show command or insert mode

set ruler " show line and column information

set showmatch " show matching brackets

set formatoptions=tcqor

set whichwrap=b,s,,[,]

syntax on

" Added by chris

" from http://items.sjbach.com/319/configuring-vim-right

set hidden

set history=1000

nnoremap ' `

nnoremap ` '

set smartcase "is case sensitive only if there's a capital letter

set title

" enables matching if/elseif/else/etc., sort of works

runtime macros/matchit.vim

"from http://blog.learnr.org/post/59098925/configuring-vim-some-mo...

map H ^

map L $

" End Added by chris

let loaded_matchparen = 1

nmap :call LoadSession()

let s:sessionloaded = 0

function LoadSession()

  source Session.vim

  let s:sessionloaded = 1
endfunction

function SaveSession()

  if s:sessionloaded == 1

    mksession!

  end
endfunction

autocmd VimLeave * call SaveSession() "Reopen your session with 'vim -S Session.vim'

Re: Ask HN: What's in your .vimrc file?

#33
set nocompatible

set backspace=indent,eol,start

if has("vms") set nobackup else set backup endif set history=50 set ruler set showcmd set incsearch

map Q gq

inoremap u

if has('mouse') set mouse=a endif

if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif

if has("autocmd")

  filetype plugin indent on

  augroup vimrcEx
  au!

  autocmd FileType text setlocal textwidth=78

  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") 
else

  set autoindent	       
endif

if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis endif

colors zenburn

:filetype plugin on

set et set sw=4 set smarttab set lbr

set t_Co=256

set backupdir=./.backup,.,/tmp set directory=.,./.backup,/tmp

set nobackup set nowritebackup

set number

compiler ruby

autocmd Filetype ruby source ~/.vim/ruby-macros.vim nnoremap :TlistToggle

let Tlist_Auto_Open=1

:set title titlestring=%set virtualedit=all

Re: Ask HN: What's in your .vimrc file?

#35

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:exp…

I love the scrolljump and scrolloff, never seen those before...also I think you may have just changed my life by showing me how to use sessions.

Re: Ask HN: What's in your .vimrc file?

#36
post #26
post #22

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. map ,q :q! map ,s :w map ,w :x nmap :set number! and ctags are especially useful

Consider doing this instead: let mapleader = "," " let g:mapleader = "," map q :q! map s :w map w :x 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.

Good idea, I'll have to add that.

Re: Ask HN: What's in your .vimrc file?

#39
post #16

Nothing. 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…

Out of curiosity, why not just wget or curl -O a file from a webserver?

Most of my work the last few years has been in the compliance and IT or Physical security (or converged) space.

The machines I am working on are not my own, and often have no access to the Internet directly.

However, I'm generally doing more "editing" than "coding" so it's not a major limitation anyway.

Post reply on HN