Just to get a few things out of the way:
- vim is what I use - if you don't fine.
- flames are useless, I use ar0n as a shield.
- you may think your editor is the best and that's fine, but this is a post about vim.
- I am not a vim expert.
- vim rules. =)
On to The Meat (tm).
I was playing a bit with my .vimrc file today and wondered what some of you out there had slapped together. I am no expert programmer and I don't live in this tool as much as some of you probably do. I was wondering if anybody would be willing to show some fancy tricks or part of their configs that they liked to share.
Here is my .vimrc (very short):
:abbr #b # ----------
set background=dark
syntax on
set smartindent
set softtabstop=4
line #1: sets an alias '#b' to '# ----------' for comments.
line #2: sets my background to dark so my gnome terminal looks ok with the syntax on.
line #3: turns syntax highlighting on.
line #4: turns smartindent on (watches for left and right curly braces for automatic insertion and removal of indentation).
line #5: mingles tabs and spaces for tabbing within your file. At my setting, if I hit tab once, it creates four spaces, if I hit it again, it creates a tab. Nice when going from one editor to another and not having too much tabs.
Anyhow, that is my config and I know its fairly sparse. Anybody else want to share?
djw
Re: Vim configs (slightly OT)
by gmax (Abbot) on May 16, 2002 at 06:08 UTC
|
_ _ _ _
(_|| | |(_|><
_|
| [reply] [Watch: Dir/Any] |
Re: Vim configs (slightly OT)
by andreychek (Parson) on May 16, 2002 at 01:53 UTC
|
Here is my current vimrc.
Some highlights of what all these settings do:
- Turn on some nifty colors, for syntax highlighting and on the status bar
- Don't use real tabs, instead, use 4 spaces whenever you hit the tab key
- Handles indentation of curlies
- Uses upper ascii characters to represent real tabs, as well as showing you when there are spaces at the end of your lines
- If you're typing out comments, and the text gets to the end of the line, make it wrap, and make sure it adds a comment for you at the beginning of the next line
- Turn off all the noisy beeping, so the terminal won't beep every time you press the cursor in the wrong direction, or make some other simple mistake
And my all-time favorite:
- Tab completion of variable names! If you hit tab with no characters before your curser, you get a normal 4 space tab. If there are characters before you cursor, it performs completion on them, allowing you to scroll forward through the options with tab, or backwards through the options with shift-tab.
" Eric Andreychek's .vimrc
set nocompatible
" turn these ON:
set digraph esckeys hidden ruler showcmd wildmenu smartindent expandta
+b
set visualbell showmatch title
" turn these OFF:
set noerrorbells nostartofline nohlsearch
" non-toggles:
set backspace=2 formatoptions=cqrt laststatus=2 shortmess=at textwidth
+=79
set whichwrap=<,>,h,l shiftwidth=4 softtabstop=4
set comments=b:#,:%,fb:-,n:>,n:)
set list listchars=tab:ùð,trail:Ü
set viminfo=%,'50,\"100,:100,n~/.viminfo
" mappings:
map Q gq
map K <NUL>
map <C-Z> :shell<CR>
map ,v :e ~/.vimrc<CR>
map ,F :view $VIMRUNTIME/filetype.vim
map ,SO :source $VIMRUNTIME/syntax/
map ,V :view $VIMRUNTIME/syntax/
map <C-A> <Home>
map <C-E> <End>
" syntax coloring!! :-)
syntax on
" some colors: "white on black"
hi comment ctermfg=darkgreen ctermbg=black guifg=darkgreen guibg=bla
+ck
" Make the status bar blue
set t_mr=^[[0;1;37;44m
" The bottom line is bold-white
set t_me=^[[m
" Shhhhh!
set t_vb=
" Mmmmm... tab completetion
function! InsertTabWrapper(direction)
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
elseif "backward" == a:direction
return "\<c-p>"
else
return "\<c-n>"
endif
endfunction
inoremap <S-tab> <c-r>=InsertTabWrapper ("backward")<cr>
inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
There are some control/escape characters in this vimrc file. If you really want to use the whole thing, don't try to copy and paste this, just snag it from my website: Eric's vimrc.
Have fun,
-Eric
Update: Oh yeah, and vim rules :-)
--
Lucy: "What happens if you practice the piano for 20 years and then end up not being rich and famous?"
Schroeder: "The joy is in the playing." | [reply] [Watch: Dir/Any] [d/l] |
Re: Vim configs (slightly OT)
by Juerd (Abbot) on May 15, 2002 at 22:30 UTC
|
set smartindent
set tabstop=8
set shiftwidth=4
set softtabstop=4
let perl_want_scope_in_variables=1
let perl_extended_vars=1
let perl_include_pod=1
colorscheme elflord
syntax on
The elflord colorscheme has bright colors, so it is easy to read, the perl_* lets are very imporant if you're serious about Perl programming:
want_scope_in_variables: give package names an other color
extended_vars: parse things like $foo{ split //, $var } for better clarity
include_pod: recognise pod and use special colors for it.
Note: It's not perl_include_POD, as all documentation says. A lot of people read the documentation, and don't have this working, so use lowercase "pod".
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] [d/l] |
Re: Vim configs (slightly OT)
by jsprat (Curate) on May 15, 2002 at 22:44 UTC
|
To catch my many typos and mismatched brackets (or any other syntax error), I add set makeprg=$VIMRUNTIME/tools/efm_perl.pl\ -c\ %\ $*
set errorformat=%f:%l:%m
To check the syntax, type :make This lets me use vim's quickfix mode to jump to directly to the next error with :cn or :cp to the previous error, among other things. | [reply] [Watch: Dir/Any] [d/l] [select] |
Re: Vim configs (slightly OT)
by dmitri (Priest) on May 15, 2002 at 22:33 UTC
|
set ai
: ) Seriously, though, I found that the less I customize my settings, the easier it is for me to work on different boxes (and I edit files on several computers daily). This way, I am not forced to recreate my setting every time I am on a different computer (gets tedious fast).
Slightly off-topic, I'd like to promote VI in Perl, my pet project. Maybe people would like to help me develop it. It is still alpha, but already usable. You can do nifty things such as
:.,+5 {$_ = reverse $_}
Cheers, Dmitri.
| [reply] [Watch: Dir/Any] |
Re: Vim configs: mine
by Aristotle (Chancellor) on May 20, 2002 at 19:33 UTC
|
Thanks to gmax for a list of excellent nodes. Here's my .vimrc: " I don't want to become awkward when editing on another machine,
" so I stick to as few and as highly effective settings as possible.
set nocompatible " we want vim, not vi
set ruler " display current position in file
set backspace=2 " BS and Del in insert mode allowed and go thro
+ugh EOLs
set number " line numbers
set scrolloff=3
set autoindent
set noerrorbells
if has("gui_running")
set guioptions-=f " fork+detach console
set guioptions-=t " no menu tear-off
colorscheme peachpuff
else
set background=dark " my console has black bg
endif
filetype plugin indent on
syntax on
" Current directory follows the file being edited
autocmd BufEnter * lcd %:p:h
" [F4] for quick :make
noremap <F4> <ESC>:make<C-M>
" [F5] toggles error window
noremap <F5> <ESC>:cope<C-M>
autocmd BufReadPost quickfix noremap <F5> <ESC>:ccl<C-M>:noremap <lt>F
+5> <lt>ESC>:cope<lt>C-M><C-M>:echo ":ccl"<C-M>
" [Ctrl-PgUp/Dn] to flip through :make errors
noremap <C-PageUp> :cp<C-M>
noremap <C-PageDown> :cn<C-M>
inoremap <C-PageUp> <ESC>:cp<C-M>i
inoremap <C-PageDown> <ESC>:cn<C-M>i
" save keystrokes on the Perl shebang
iabbrev #!p #!/usr/bin/perl -w<C-M>use strict;<C-M><ESC>:filetype dete
+ct<C-M>i
These settings, as they should be, are not language specific (except the abbr). Along with this rc, for Perl coding I have a .vim/ftplugin/perl.vim:" Vim filetype plugin file
" Language: Perl
" Maintainer: Dan Sharp <vimuser@crosswinds.net>
" Last Change: Sun, 19 May 2002 02:07:22 Central European Standard
+Time
" Changed By: Aristotle Pagaltzis <pagaltzis@gmx.de>
if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1
" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
setlocal fo-=t fo+=croql
setlocal comments=:#
" Make sure the continuation lines below do not cause problems in
" compatibility mode.
set cpo-=C
" Change the browse dialog on Win32 to show mainly Perl-related files
if has("gui_win32") && !exists("b:browsefilter")
let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
\ "Perl Modules (*.pm)\t*.pm\n" .
\ "Perl Documentation Files (*.pod)\t*.pod\n" .
\ "All Files (*.*)\t*.*\n"
endif
" Provided by Ned Konz <ned@bike-nomad.com>
"---------------------------------------------
setlocal include=\\<\\(use\|require\\)\\s*
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','
+.pm','')
setlocal isfname=A-Z,a-z,:,48-57,_
setlocal isident=48-57,_,A-Z,a-z
setlocal iskeyword=48-57,_,A-Z,a-z,:
setlocal define=[^A-Za-z_]
" Set this once, globally.
if !exists("perlpath")
if &shellxquote != '"'
let perlpath = system('perl -e "print join(q/,/,@INC)"')
else
let perlpath = system("perl -e 'print join(q/,/,@INC)'")
endif
let perlpath = substitute(perlpath,',.$',',,','')
endif
let &l:path=perlpath
setlocal keywordprg=perldoc
setlocal makeprg=perl\ -Mstrict\ -wc\ %
setlocal errorformat+=%m\ at\ %f\ line\ %l.
setlocal grepprg=rgrep\ -n\ -R\ '*.p[ml]'\ $*
map <buffer> <C-]> :exec ":tag /".expand("<cword>")
____________ Makeshifts last the longest. | [reply] [Watch: Dir/Any] [d/l] [select] |
Re: Vim configs (slightly OT)
by bsb (Priest) on Apr 16, 2003 at 01:19 UTC
|
Here are some things I use which I haven't seen
elsewhere in Perl Monks.
let perl_fold = 1
" copy & comment current line with #
map <F6> yypkI#<ESC>j
" format inner para
map <F7> !ipperl -MText::Autoformat -eautoformat<CR>
au BufRead,BufNewFile *.pm,*.pl setlocal keywordprg=perldoc\ -f
" Only fold if bigger than window
function SetFoldLevel()
"echo "Win:" . winheight(0) . " lines:" . line("$")
if winheight(0) >= line("$")
set foldlevel=99
"echo "open"
else
set foldlevel=1
"echo "closed"
endif
endfunction
autocmd BufRead * call SetFoldLevel()
| [reply] [Watch: Dir/Any] |
|
|