View previous topic :: View next topic |
Author |
Message |
dingo n00b

Joined: 18 Aug 2002 Posts: 58
|
Posted: Fri Dec 17, 2004 9:59 am Post subject: Vim users: post your cool/useful config tips! |
|
|
I Saw alot of topics on vim here, and thought i'd throw in my own .vimrc, its a few years old. I mostly code in C, bash, and python on openbsd
Code: |
" key mappings
au BufNewFile,BufRead *.c,*.cpp map <F7> :!make %:r<cr>
au BufNewFile,BufRead *.py map <F7> :!python %<cr>
au BufNewFile,BufRead *.php map <F7> :!php %<cr>
au BufNewFile,BufRead *.c map <F6> :!cc % -o %:r<cr>
au BufNewFile,BufRead *.cpp map <F6> :!g++ % -o %:r<cr>
au BufNewFile,BufRead *.py map <F6> :!python %
au BufNewFile,BufRead *.c,*.cpp map <F5> :!./%:r<cr>
au BufNewFile,BufRead *.sh,*.py,*.pl map <F5> :!./%<cr>
au BufNewFile,BufRead sshd_config map <f7> :!pkill -HUP sshd
au BufNewFile,BufRead sshd_config,ssh_config map <f6> :!ssh
au BufNewFile,BufRead inetd.conf map <f7> :!pkill -HUP inetd
au BufNewFile,BufRead inetd.conf map <f7> :!telnet localhost
au BufNewFile,BufRead pf.conf map <F7> :!pfctl -f /etc/pf.conf<cr>
au BufNewFile,BufRead pf.conf map <f6> :!pfctl -
au BufNewFile,BufRead pf.conf map <f5> :!tcpdump -ttt -vvv -X -s256 -e -i pflog0
" Terminal Output Filtering
colorscheme desert
au BufNewFile,BufRead *.c,*.cpp set list listchars=tab:·.,trail:·
au BufNewFile,BufRead *.py,*.html,*.sh set list listchars=tab:..,trail:·,extends:»
au BufNewFile,BufRead *.c,*.cpp,*.h set tw=79
au BufNewFile,BufRead *.c,*.cpp,*.h,*.py,*.php set tabstop=3
au BufNewFile,BufRead *.sh,*.html set tabstop=3
au BufNewFile,BufRead *.txt if &tw == 0 | set tw=78 | endif
au BufNewFile,BufRead *.txt set linebreak
au BufNewFile,BufRead *.py set expandtab " write spaces instead of tabs
" Interactive
au BufNewFile,BufRead *.c,*.cpp,*.h,*.py,*.html,*.sh,*.php set autoindent
au BufNewFile,BufRead *.c,*.cpp,*.h,*.py,*.html,*.sh,*.php set smartindent
au BufNewFile,BufRead *.c,*.cpp,*.h,*.py,*.html,*.sh,*.php set backspace=indent,start
au BufNewFile,BufRead *.c,*.cpp,*.py,*.php set shiftwidth=3
au BufNewFile,BufRead *.py set smarttab " backspace over expandtab
au BufNewFile,BufRead *.sh,*.html set shiftwidth=2
au BufNewFile,BufRead *.sh,*.py,*.html set nowrap
au BufNewFile,BufRead *.sh,*.py,*.html set go+=b " horizontal scrolling
au BufNewFile,BufRead *.txt set joinspaces " wo spaces after punctuation on J
"set expandtab
" reading Ms-Word documents, requires antiword
au BufReadPre *.doc set ro
au BufReadPre *.doc set hlsearch!
au BufReadPost *.doc %!antiword "%"
" Terminal Input
set nocompatible " Use Vim defaults
" Terminal Output
set ttyfast " fast terminal connection, redaws cleaner
set lazyredraw " slow terminal
set showcmd
set ruler
" Colors
syntax on
"set backup " Keep a backup file
"Scratch Pad - enable/disable as needed
"
"set tw=79 " force oldschool text width
"set tabstop=2
"set shiftwidth=2
"set softtabstop=2
"set pastetoggle=<F11> " f11 for pasting or turning on/off indent
"set list listchars=tab:»·,trail:· " Highlights tabs
"set list listchars=trail:»
"set list listchars=trail:·
"set viminfo='999,\"999 " Read/write a .viminfo file
"set history=9999 " 50 lines of command history
"set modelines=0 " Gentoo security advisory
" Searching
"nnoremap <CR> :noh<CR><CR> " Un-highlight text after when enter
set hlsearch " highlight searches
set ignorecase " case insensitive searches
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=utf-8,latin1
endif
if &term=="xterm"
set t_RV= " don't check terminal version
set t_Co=8
set t_Sb=^[4%dm
set t_Sf=^[3%dm
endif
if has("gui_running")
if has("gui_gtk2")
set guifont=Courier\ New\ 29
elseif has("x11")
" You may want to lower the font size or change font types.
"I run 1280x1024 or higher, and this is the largest terminal-like
"font i can stand.
set guifont=-adobe-courier-*-r-*-*-12-*-*-*-*-*-*-*
else
set guifont=Courier_New:h20:cDEFAULT
endif
endif
" Jump to last cusor location
au BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
|
|
|
Back to top |
|
 |
pjp Administrator


Joined: 16 Apr 2002 Posts: 18154
|
Posted: Fri Dec 17, 2004 6:22 pm Post subject: |
|
|
This is likely to become a repository where people post their .vimrc files. While not a bad thing, it isn't really appropriate for DT&T.
Moved from Documentation, Tips & Tricks. _________________ Those who know what's best for us must rise and save us from ourselves. |
|
Back to top |
|
 |
dingo n00b

Joined: 18 Aug 2002 Posts: 58
|
Posted: Fri Dec 17, 2004 7:24 pm Post subject: |
|
|
All kinds of tips and tricks in there, ah well. |
|
Back to top |
|
 |
rezza Guru


Joined: 09 Apr 2003 Posts: 434 Location: Edinburgh, UK
|
Posted: Fri Dec 17, 2004 7:43 pm Post subject: |
|
|
A few good ideas in there. Mine is here, but I'm gonna merge some of your stuff into mine soon. _________________ screenshots
blog |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Sat Dec 18, 2004 2:16 am Post subject: |
|
|
Woah that's pretty hefty.
Anyway, here's mine: Code: | :se nu
:set printoptions=number:y
:set nocompatible
:set tabstop=2
:set expandtab
:set shiftwidth=1
:set autoindent
:set autowrite | Then again, I likely have yet to do more than scratch the surface of Vim's capabilites.
 _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
Irom Tux's lil' helper


Joined: 07 Oct 2003 Posts: 93 Location: am arsch..
|
Posted: Sat Dec 18, 2004 11:43 am Post subject: |
|
|
Here are a few vim-things I can't live without anymore:
Code: | nnoremap <silent><F12> :set hls!<cr>
inoremap <silent><F12> <Esc>:set hls!<cr>a
nnoremap <silent>n :set hls<cr>n
nnoremap <silent>N :set hls<cr>N
nnoremap <silent>* :set hls<cr>*
nnoremap <silent># :set hls<cr>#
nnoremap <silent>/ :set hls<cr>/
nnoremap <silent>? :set hls<cr>?
| This toggles the highlighting of the last search with F12. It's automatically turned on again with a new search.
Code: | nmap <silent><F6> :m+<CR>
nmap <silent><F5> :m-2<CR>
imap <silent><F6> <esc>:m .+1<CR>a
imap <silent><F5> <esc>:m .-2<CR>a
vmap <silent><F6> :m '>+<CR>gv
vmap <silent><F5> :m-2<CR>gv
| This moves the current line or selection one line up/down with F5/F6
Some small maps:
Code: | " toggle "list" with F10
noremap <silent><F10> :set list!<cr>
inoremap <silent><F10> <ESC>:set list!<cr>a
" toggle "paste" with F11
set pastetoggle=<F11>
" switch between buffers with F7 and F8
nnoremap <silent><F8> :bn<cr>
inoremap <silent><F8> <Esc>:bn<cr>
nnoremap <silent><F7> :bp<cr>
inoremap <silent><F7> <Esc>:bp<cr>
|
My full configuration is here. Comments in German, sorry. But there is always :help. _________________ http://ftp.fukt.bsnet.se/pub/movies/stallman/ (Please watch this before you form an opinion about GNU)
https://apfelboymchen.net/gnu/
Last edited by Irom on Sat Jan 08, 2005 1:13 am; edited 1 time in total |
|
Back to top |
|
 |
Gherald Veteran


Joined: 23 Aug 2004 Posts: 1399 Location: CLUAConsole
|
Posted: Sat Dec 18, 2004 12:05 pm Post subject: |
|
|
on a related note, if you edit ebuilds with vim you'll like:
Code: | emerge gentoo-syntax |
I have a feeling it's gonna become a lot longer once I have time to look through all of yours', but here's my extremely newbish setup:
Code: | map <F1> <ESC>
map! <F1> <ESC>
nmap <F1> <ESC>
vmap <F1> <ESC>
omap <F1> <ESC>
cmap <F1> <ESC>
imap <F1> <ESC>
set nohlsearch
filetype plugin on
filetype indent on
|
basically I got sick and tired of hitting F1 instead of ESC on my laptop and of the persistent search highlighting.
vim is awesome; thanks to all who post. |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Tue Dec 27, 2005 6:40 pm Post subject: Vim users: post your cool/useful config tips! |
|
|
I apologize if this has been posted before, but I searched via the forums search tool and Google's "site:forums.gentoo.org" query and did not find anything similar....
Vim users, what "cool," "nifty," or other useful options do you use in your .vimrc files? Mine (Windows at work) consists of: Code: | set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set nu
set noexpandtab
set tabstop=4
colorscheme koehler
set guifont=Bitstream_Vera_Sans_Mono:h11 | Ok so it's nothing special, but it works lovely.
Share yours!  _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
Chaosite Guru


Joined: 13 Dec 2003 Posts: 540 Location: Right over here.
|
Posted: Tue Dec 27, 2005 6:57 pm Post subject: |
|
|
Well... Every vimrc discussion should probably include ciaranm's huge-ass one.
Thar be dragons.
URL tag fixed up. --codergeek42 |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Tue Dec 27, 2005 6:59 pm Post subject: |
|
|
Holy jeebus. *goes off to try to understand it* _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
syscrash Guru


Joined: 14 Apr 2003 Posts: 541
|
Posted: Tue Dec 27, 2005 7:05 pm Post subject: |
|
|
Code: | version 6.0
if &cp | set nocp | endif
let s:cpo_save=&cpo
set cpo&vim
map! <S-Insert> *
map! <xHome> <Home>
map! <xEnd> <End>
map! <S-xF4> <S-F4>
map! <S-xF3> <S-F3>
map! <S-xF2> <S-F2>
map! <S-xF1> <S-F1>
map! <xF4> <F4>
map! <xF3> <F3>
map! <xF2> <F2>
map! <xF1> <F1>
map Q gq
map <xHome> <Home>
map <xEnd> <End>
map <S-xF4> <S-F4>
map <S-xF3> <S-F3>
map <S-xF2> <S-F2>
map <S-xF1> <S-F1>
map <xF4> <F4>
map <xF3> <F3>
map <xF2> <F2>
map <xF1> <F1>
let &cpo=s:cpo_save
unlet s:cpo_save
set autoindent
set background=dark
set backspace=2
set fileencodings=ucs-bom,utf-8,default
set guifont=Bitstream\ Vera\ Sans\ Mono\ 8
set guioptions=agimrLt
set history=50
set hlsearch
set nomodeline
set mouse=a
set mousemodel=popup
set ruler
set suffixes=.bak,~,.o,.h,.info,.swp,.obj,.info,.aux,.log,.dvi,.bbl,.out
set termencoding=utf-8
set viminfo='20,\"500
if has("gui_running")
colorscheme brookstream
endif
set nu
set nohlsearch |
Nothing special in there, just the colorscheme part (which only takes effect in gvim so that your command-line vim won't have crazy colours.) _________________ Play ET? Come by #gentoo.et on freenode!
http://syscrash.ca |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Thu Jan 05, 2006 11:13 pm Post subject: |
|
|
No one else uses (g)vim? How disheartening.  _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
jakamaka Apprentice


Joined: 17 Jun 2004 Posts: 266 Location: My self-sustainable fusion of thought
|
Posted: Thu Jan 05, 2006 11:27 pm Post subject: |
|
|
codergeek42 wrote: | No one else uses (g)vim? How disheartening.  |
I can actually work faster with plain old vim. _________________ It would be more interesting to learn from children, than try to teach them how to behave, how to live and how to function. - U.G. Krishnamurti |
|
Back to top |
|
 |
Zepp Veteran


Joined: 15 Mar 2004 Posts: 1246 Location: Ontario, Canada
|
Posted: Fri Jan 06, 2006 2:04 am Post subject: |
|
|
codergeek42 wrote: | No one else uses (g)vim? How disheartening.  |
I usually use gvim, but I just started using vim so I still got a get a handle on it all  |
|
Back to top |
|
 |
Fenster Apprentice


Joined: 26 Oct 2004 Posts: 172 Location: Purgatory
|
Posted: Fri Jan 06, 2006 2:22 am Post subject: |
|
|
Code: | set guifont=Bitstream_Vera_Sans_Mono:h11
set textwidth=150
set formatoptions-=t
set mouse=a
set ruler |
My settings are as they are because I use vim to write drafts of documents which I later clean up using OO.
Same font as codergeek too, hah.  _________________ photography - geekery |
|
Back to top |
|
 |
hermes_jr l33t


Joined: 26 Feb 2004 Posts: 701 Location: Moscow, Russia
|
Posted: Fri Jan 06, 2006 2:37 am Post subject: |
|
|
Code: |
set whichwrap=b,s,<,>,[,]
startinsert
colorscheme desert
set guioptions=agimrLt
set ignorecase
set nohlsearch
set tabstop=4
set number
set mousef
set nowrap
set tildehide
|
As for startinsert, ignorecase and whichwrap - all clear, just simulating common text editors behaviour. And tildehide... Well this one is more like useless, but on the other side is something unusual (so I guess it worth posting here ) |
|
Back to top |
|
 |
TNorthover Guru


Joined: 25 Jan 2004 Posts: 434 Location: Edinburgh, UK
|
Posted: Fri Jan 06, 2006 10:53 am Post subject: |
|
|
jakamaka wrote: | I can actually work faster with plain old vim. |
I use gvim, but only because I think it looks better than plain vim (the fonts I like for coding are different ones than for shell-work). I can't remember the last time I used the mouse in it. |
|
Back to top |
|
 |
rezza Guru


Joined: 09 Apr 2003 Posts: 434 Location: Edinburgh, UK
|
Posted: Fri Jan 06, 2006 11:26 am Post subject: |
|
|
Mine. I use vim 7. _________________ screenshots
blog |
|
Back to top |
|
 |
allucid Veteran

Joined: 02 Nov 2002 Posts: 1314 Location: atlanta
|
Posted: Fri Jan 06, 2006 11:29 am Post subject: |
|
|
you can use instead of to save and exit.  |
|
Back to top |
|
 |
cokey Advocate


Joined: 23 Apr 2004 Posts: 3343
|
Posted: Fri Jan 06, 2006 12:41 pm Post subject: |
|
|
how do you set it to use ctrl+v and ctrl+c etc that normal ones use? _________________ "Sex: breakfast of champions" - James Hunt |
|
Back to top |
|
 |
mark_alec Bodhisattva


Joined: 11 Sep 2004 Posts: 6066 Location: Melbourne, Australia
|
Posted: Fri Jan 06, 2006 12:49 pm Post subject: |
|
|
Or you can _________________ www.gentoo.org.au || #gentoo-au |
|
Back to top |
|
 |
codergeek42 Bodhisattva

Joined: 05 Apr 2004 Posts: 5142 Location: Anaheim, CA (USA)
|
Posted: Fri Jan 06, 2006 4:28 pm Post subject: |
|
|
That's cool, rezza. Thanks.  _________________ ~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF |
|
Back to top |
|
 |
cokey Advocate


Joined: 23 Apr 2004 Posts: 3343
|
Posted: Sat Jan 07, 2006 12:13 am Post subject: |
|
|
how do i make all the weird controls work like other editors? I'm too lazy to learn. _________________ "Sex: breakfast of champions" - James Hunt |
|
Back to top |
|
 |
TNorthover Guru


Joined: 25 Jan 2004 Posts: 434 Location: Edinburgh, UK
|
Posted: Sat Jan 07, 2006 9:53 am Post subject: |
|
|
cokehabit wrote: | how do i make all the weird controls work like other editors? I'm too lazy to learn. |
Probably the easiest way:
Code: | su
rm /usr/bin/vim
ln -s /usr/bin/nano /usr/bin/vim |
|
|
Back to top |
|
 |
sn4ip3r Guru


Joined: 14 Dec 2002 Posts: 325 Location: Tallinn, Estonia
|
Posted: Sat Jan 07, 2006 10:03 am Post subject: |
|
|
TNorthover wrote: | cokehabit wrote: | how do i make all the weird controls work like other editors? I'm too lazy to learn. |
Probably the easiest way:
Code: | su
rm /usr/bin/vim
ln -s /usr/bin/nano /usr/bin/vim |
|
No, Code: | echo "set insertmode" >> ~/.vimrc |
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|