View previous topic :: View next topic |
Author |
Message |
Cr0t l33t
Joined: 27 Apr 2002 Posts: 944 Location: USA
|
Posted: Wed Jun 05, 2002 2:52 am Post subject: VIm fancy |
|
|
Code: | let color = "true"
if has("syntax")
if color == "true"
" This will switch colors ON
so ${VIMRUNTIME}/syntax/syntax.vim
else
" this switches colors OFF
syntax off
set t_Co=0
endif
endif
set bs=2
set cin | copy and past the code into .vimrc and put the file into your home dir. _________________ cya |
|
Back to top |
|
|
mksoft l33t
Joined: 28 May 2002 Posts: 844
|
Posted: Wed Jun 05, 2002 3:36 pm Post subject: |
|
|
While at it you can add:
Code: | " Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
|
_________________ There's someone in my head but it's not me - Pink Floyd |
|
Back to top |
|
|
ChiaJesus n00b
Joined: 08 Jun 2002 Posts: 51
|
Posted: Mon Jun 10, 2002 1:59 am Post subject: Great Tip |
|
|
This is a really good tip. Thanks for sharing it!
-Chia |
|
Back to top |
|
|
DArtagnan l33t
Joined: 30 Apr 2002 Posts: 942 Location: Israel, Jerusalem
|
Posted: Mon Jun 10, 2002 8:00 am Post subject: |
|
|
yeap,
i copied it too _________________ All for one and one for All
--
MACPRO machine... |
|
Back to top |
|
|
RoadRunner Bodhisattva
Joined: 12 Jun 2002 Posts: 490 Location: Coimbra, Portugal
|
Posted: Wed Jun 12, 2002 9:58 am Post subject: |
|
|
Yeah, nice tip! Thanks a lot |
|
Back to top |
|
|
michaelb l33t
Joined: 06 Jun 2002 Posts: 686 Location: Ann Arbor, MI
|
Posted: Tue Jun 18, 2002 7:54 pm Post subject: |
|
|
more VIM goodness... Add some autocommands to your .vimrc file!
My favs:
Code: |
" Note: In Vim a continuation line starts with \
:autocmd FileType *
\ set formatoptions=tcql nocindent comments&
:autocmd FileType c,cpp
\ set formatoptions=croql cindent
\ comments=sr:/*,mb:*,ex:*/,://
:set autoindent
:set autowrite
|
This will help with C and C++ code beautification.
For a full listing of autocommands
|
|
Back to top |
|
|
masseya Bodhisattva
Joined: 17 Apr 2002 Posts: 2602 Location: Baltimore, MD
|
Posted: Wed Jun 19, 2002 5:08 am Post subject: more options.. |
|
|
Here's some more good options for programmers (non-python): Code: | set tabstop=2
set expandtab
set shiftwidth=1 |
_________________ if i never try anything, i never learn anything..
if i never take a risk, i stay where i am.. |
|
Back to top |
|
|
masseya Bodhisattva
Joined: 17 Apr 2002 Posts: 2602 Location: Baltimore, MD
|
Posted: Wed Jul 10, 2002 4:41 am Post subject: SuperTab |
|
|
Also, if you are looking for a neato tab completion utility check out SuperTab. It is pretty cool. Basically, you could be programming and have a variable named: really_descriptive but all you would have to type to reference it would be: rea <tab>. It's really helpful. _________________ if i never try anything, i never learn anything..
if i never take a risk, i stay where i am.. |
|
Back to top |
|
|
delta407 Bodhisattva
Joined: 23 Apr 2002 Posts: 2876 Location: Chicago, IL
|
Posted: Wed Jul 10, 2002 4:44 am Post subject: Re: SuperTab |
|
|
Tristam29 wrote: | Basically, you could be programming and have a variable named: really_descriptive but all you would have to type to reference it would be: rea <tab>. It's really helpful. |
So... sorta like bash. Cool. _________________ I don't believe in witty sigs. |
|
Back to top |
|
|
grakker Tux's lil' helper
Joined: 17 Apr 2002 Posts: 100
|
Posted: Wed Jul 10, 2002 5:14 am Post subject: |
|
|
Way back when I was taking first year C programming, I found vi to be super slick. I can't remember if it was out of the box or not (I think so though) but after first typing a variable or function, I could type the first few letters of the name, then hit cntrl-p and it would cycle through names that matched the pattern.
But even cooler than that was a .vimrc setting that I downloaded from somewhere that let me compile from inside vi and if the compiler farted on a syntax error or whatever, it would return to the line where the error occurred. I don't know if I explained that very well, but it sure made that first semester easy.
Haven't programmed in awhile, but I still have a pretty warm spot for vim. |
|
Back to top |
|
|
rojaro l33t
Joined: 06 May 2002 Posts: 732
|
Posted: Wed Jul 10, 2002 9:25 pm Post subject: comment colors ... |
|
|
here my two cents ... :)
most people use a black background on the console and the terminal/ssh clients. as vim uses the dark-blue color for comments they're often hardly readable (depending on the montior). add the following line:
Code: | hi Comment term=bold ctermfg=6 guifg=Blue |
ctermfg defines the color, which is in the example cyan, which is much better readable. _________________ A mathematician is a machine for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970) |
|
Back to top |
|
|
riksta n00b
Joined: 16 Apr 2004 Posts: 73 Location: Manchester, UK
|
Posted: Sun Aug 29, 2004 2:26 am Post subject: |
|
|
here is a little tip from me, some of you may know it...some may not
When pasting into vim from say, a webpage, if all the layout of the text gets all auto indented (and pushed further and further right), before you press i to paste, type
simlarly its nopaste to turn it back on |
|
Back to top |
|
|
Twink Apprentice
Joined: 06 Dec 2002 Posts: 178 Location: New Zealand
|
Posted: Sun Aug 29, 2004 4:27 am Post subject: Re: SuperTab |
|
|
masseya wrote: | Also, if you are looking for a neato tab completion utility check out SuperTab. It is pretty cool. Basically, you could be programming and have a variable named: really_descriptive but all you would have to type to reference it would be: rea <tab>. It's really helpful. |
isn't that just like pressing ctrl-P or ctrl-N while in insert mode? |
|
Back to top |
|
|
riksta n00b
Joined: 16 Apr 2004 Posts: 73 Location: Manchester, UK
|
Posted: Sun Aug 29, 2004 1:39 pm Post subject: |
|
|
well i just tried that ctrl+p and it doesnt work for me..i get:
-- Keyword completion (^N^P) Pattern not found |
|
Back to top |
|
|
Narada Guru
Joined: 12 Dec 2002 Posts: 300 Location: London, UK
|
Posted: Sun Aug 29, 2004 7:08 pm Post subject: |
|
|
Add the code below to ~/.vimrc to set an F10 shortcut for pasting. So, before pasting, press i to go into insert mode and press F10 to enter paste mode. The order in which you press these doesn't matter. Code: | set pastetoggle=<F10> |
_________________ http://dhruba.name/ |
|
Back to top |
|
|
hanzotutu Apprentice
Joined: 10 Apr 2003 Posts: 170
|
Posted: Sun Aug 29, 2004 7:13 pm Post subject: |
|
|
how to set expandtab if I am editing a fortran code (*.f)
I tried
Code: |
autocmd FileType f set expandtab
|
but it doesn't work. _________________ Dell D600, P-M 1.4G, 512M DDR, Radeon M9 32M |
|
Back to top |
|
|
minaguib n00b
Joined: 03 Nov 2003 Posts: 35 Location: Montréal
|
Posted: Mon Aug 30, 2004 4:35 am Post subject: |
|
|
Here are some chunks from my .vimrc file that you guys might find useful:
Code: |
set nobk
set ignorecase
set smartcase
set ttyfast
set visualbell t_vb=
set smarttab
set autoindent
set title
set ruler
set splitbelow
set tabstop=3
set shiftwidth=3
set wildignore=*.bak,~,*.o,*.info,*.swp,*.class,*.aux,*.log,*.tmp,*.tar,*.gz,*.tgz
set tags=./tags;../tags;../../tags;../../../tags;../../../../tags;~/tags
set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
set complete-=k complete+=k
set modeline
vnoremap < <gv
vnoremap > >gv
nmap n nmzz.`z
nmap N Nmzz.`z
nmap * *mzz.`z
nmap # #mzz.`z
nmap g* g*mzz.`z
nmap g# g#mzz.`z
map <C-P> :w !$ALIASPERL<CR>
map c<C-P> :w !$ALIASPERL -cw<CR>
map t<C-P> :%!perltidy -q -et=4 -l=0 -pt=2 -bar -cab=0 2>/dev/null<CR>
map <C-N> n
map <Space> za
syntax on
let perl_fold=1
autocmd BufWritePost *.pl,*.pm,*.cgi !$ALIASPERL -c %
autocmd BufEnter *.pl,*.pm,*.cgi let oldkp=&kp | set keywordprg=$ALIASPERL\ -e\ '$c=shift;exec\"$ALIASPERLDOC\".($c=~/^[a-z]+$/?\"\ -f\ \":\"\ \").$c'
autocmd BufLeave *.pl,*.pm,*.cgi let &keywordprg=oldkp
if version >= 600
set guifont=Terminus\ 11
set wildmenu
filetype plugin indent on
set dy=uhex
silent! source ~/dotfiles/colorscheme.vim
silent! source ~/dotfiles/taglist.vim
let Tlist_Ctags_Cmd=$ALIASCTAGS
let Tlist_Sort_Type="name"
let Tlist_Compact_Format=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Inc_Winwidth=0
nnoremap <silent> <F8> :Tlist<CR>
nnoremap <silent> <F7> :TlistUpdate<CR>
silent! source ~/dotfiles/EasyAccents.vim
endif
|
|
|
Back to top |
|
|
hanzotutu Apprentice
Joined: 10 Apr 2003 Posts: 170
|
Posted: Mon Aug 30, 2004 6:38 am Post subject: |
|
|
hanzotutu wrote: | how to set expandtab if I am editing a fortran code (*.f)
I tried
Code: |
autocmd FileType f set expandtab
|
but it doesn't work. |
I figured out by myself.....add this line to .vimrc will do the trick
Code: |
autocmd FileType fortran set expandtab
|
_________________ Dell D600, P-M 1.4G, 512M DDR, Radeon M9 32M |
|
Back to top |
|
|
Wi1d Apprentice
Joined: 15 Mar 2004 Posts: 282 Location: USA, Iowa
|
Posted: Mon Aug 30, 2004 9:01 am Post subject: |
|
|
Great tips. I really like the 'set pastetoggle=<F10>'. I do have a question maybe someone knows the answer to. When using vim & mutt to write and then edit an email, the revised version can look really chopped up, because of textwidth, leaving alot of partial lines and more editing work. Anyone know of a way to prevent this? |
|
Back to top |
|
|
tactless l33t
Joined: 14 Jul 2002 Posts: 642 Location: Mitzpe Adi, Israel
|
Posted: Mon Aug 30, 2004 9:11 am Post subject: Re: VIm fancy |
|
|
Cr0t wrote: | Code: | let color = "true"
if has("syntax")
if color == "true"
" This will switch colors ON
so ${VIMRUNTIME}/syntax/syntax.vim
else
" this switches colors OFF
syntax off
set t_Co=0
endif
endif
|
|
Actually, this would suffice:
rojaro wrote: | most people use a black background on the console and the terminal/ssh clients. as vim uses the dark-blue color for comments they're often hardly readable (depending on the montior). add the following line:
Code: | hi Comment term=bold ctermfg=6 guifg=Blue |
ctermfg defines the color, which is in the example cyan, which is much better readable. |
Slightly better way to do avoid this problem:
And if you use the GUI:
Code: | hi Normal guibg=black guifg=white |
_________________ Tactless
"If it wasn't for fog, the world would run at a really crappy framerate."
Jabber: tactless@amessage.info |
|
Back to top |
|
|
kashani Advocate
Joined: 02 Sep 2002 Posts: 2032 Location: San Francisco
|
Posted: Fri Dec 10, 2004 12:47 am Post subject: |
|
|
and if you're using SecureCRT under Windows to connect to your Linux box you must set your term type to be'linux' and then set ANSI color for color to work right. vt100 and other nonsense will show you shell colors, but it won't work for vim and other things.
kashani _________________ Will personally fix your server in exchange for motorcycle related shop tools in good shape. |
|
Back to top |
|
|
Bushwack n00b
Joined: 16 Jan 2004 Posts: 14
|
Posted: Fri Dec 10, 2004 1:12 am Post subject: |
|
|
Narada wrote: | Add the code below to ~/.vimrc to set an F10 shortcut for pasting. So, before pasting, press i to go into insert mode and press F10 to enter paste mode. The order in which you press these doesn't matter. Code: | set pastetoggle=<F10> |
|
Taking it one step furthur:
Code: | nmap <silent> <C-V> :set paste<CR>"*p:set nopaste<CR> |
Here's a couple more from my vimrc:
Code: | au Syntax * syn match Error /\s\+$\| \+\ze\t/ " highlight extra whitespace
set incsearch " make search like the mozilla find as you type
|
|
|
Back to top |
|
|
Wi1d Apprentice
Joined: 15 Mar 2004 Posts: 282 Location: USA, Iowa
|
Posted: Fri Dec 10, 2004 9:06 pm Post subject: |
|
|
Wi1d wrote: | Great tips. I really like the 'set pastetoggle=<F10>'. I do have a question maybe someone knows the answer to. When using vim & mutt to write and then edit an email, the revised version can look really chopped up, because of textwidth, leaving alot of partial lines and more editing work. Anyone know of a way to prevent this? |
Here is what you do to fix that. Put the following into your .vimrc file:
Code: | nnoremap R gqap
vnoremap R gq |
Then after you edit your emails do a <shift>V to highlight the edited area and then hit <shift>R rewrap your lines. |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Sun Dec 12, 2004 4:09 pm Post subject: |
|
|
Emerge app-vim/gentoo-syntax for syntax files for Gentoo configuration files like /etc/portage/packages.keywords. |
|
Back to top |
|
|
sireyessire Advocate
Joined: 20 Mar 2003 Posts: 2991 Location: back in Paris, France
|
Posted: Thu Dec 16, 2004 1:54 pm Post subject: |
|
|
Leffe wrote: | Emerge app-vim/gentoo-syntax for syntax files for Gentoo configuration files like /etc/portage/packages.keywords. |
For fluxbox users there is also a package for highlighting syntax:
app-vim/fluxbox-syntax _________________ I never think of the future. It comes soon enough.
Albert Einstein
Try simpler first
Shockley |
|
Back to top |
|
|
|