Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
VIm fancy
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Cr0t
l33t
l33t


Joined: 27 Apr 2002
Posts: 895
Location: USA

PostPosted: Wed Jun 05, 2002 2:52 am    Post subject: VIm fancy Reply with quote

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
    ©®0t
Back to top
View user's profile Send private message
mksoft
l33t
l33t


Joined: 28 May 2002
Posts: 844

PostPosted: Wed Jun 05, 2002 3:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
ChiaJesus
n00b
n00b


Joined: 08 Jun 2002
Posts: 51

PostPosted: Mon Jun 10, 2002 1:59 am    Post subject: Great Tip Reply with quote

This is a really good tip. Thanks for sharing it!

-Chia
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Mon Jun 10, 2002 8:00 am    Post subject: Reply with quote

yeap,
i copied it too :-)
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
RoadRunner
Moderator
Moderator


Joined: 12 Jun 2002
Posts: 490
Location: Coimbra, Portugal

PostPosted: Wed Jun 12, 2002 9:58 am    Post subject: Reply with quote

Yeah, nice tip! Thanks a lot
Back to top
View user's profile Send private message
michaelb
l33t
l33t


Joined: 06 Jun 2002
Posts: 686
Location: Ann Arbor, MI

PostPosted: Tue Jun 18, 2002 7:54 pm    Post subject: Reply with quote

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
Code:

:help autocmd
Back to top
View user's profile Send private message
masseya
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 2602
Location: Raleigh, NC

PostPosted: Wed Jun 19, 2002 5:08 am    Post subject: more options.. Reply with quote

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
View user's profile Send private message
masseya
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 2602
Location: Raleigh, NC

PostPosted: Wed Jul 10, 2002 4:41 am    Post subject: SuperTab Reply with quote

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
View user's profile Send private message
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Wed Jul 10, 2002 4:44 am    Post subject: Re: SuperTab Reply with quote

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. :D
_________________
I don't believe in witty sigs.
Back to top
View user's profile Send private message
grakker
Tux's lil' helper
Tux's lil' helper


Joined: 17 Apr 2002
Posts: 100

PostPosted: Wed Jul 10, 2002 5:14 am    Post subject: Reply with quote

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
View user's profile Send private message
rojaro
l33t
l33t


Joined: 06 May 2002
Posts: 732

PostPosted: Wed Jul 10, 2002 9:25 pm    Post subject: comment colors ... Reply with quote

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
View user's profile Send private message
riksta
n00b
n00b


Joined: 16 Apr 2004
Posts: 73
Location: Manchester, UK

PostPosted: Sun Aug 29, 2004 2:26 am    Post subject: Reply with quote

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

Code:

:set paste


simlarly its nopaste to turn it back on :D
Back to top
View user's profile Send private message
Twink
Apprentice
Apprentice


Joined: 06 Dec 2002
Posts: 178
Location: New Zealand

PostPosted: Sun Aug 29, 2004 4:27 am    Post subject: Re: SuperTab Reply with quote

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
View user's profile Send private message
riksta
n00b
n00b


Joined: 16 Apr 2004
Posts: 73
Location: Manchester, UK

PostPosted: Sun Aug 29, 2004 1:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Narada
Guru
Guru


Joined: 12 Dec 2002
Posts: 300
Location: London, UK

PostPosted: Sun Aug 29, 2004 7:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
hanzotutu
Apprentice
Apprentice


Joined: 10 Apr 2003
Posts: 170

PostPosted: Sun Aug 29, 2004 7:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
minaguib
n00b
n00b


Joined: 03 Nov 2003
Posts: 35
Location: Montréal

PostPosted: Mon Aug 30, 2004 4:35 am    Post subject: Reply with quote

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
View user's profile Send private message
hanzotutu
Apprentice
Apprentice


Joined: 10 Apr 2003
Posts: 170

PostPosted: Mon Aug 30, 2004 6:38 am    Post subject: Reply with quote

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
View user's profile Send private message
Wi1d
Apprentice
Apprentice


Joined: 15 Mar 2004
Posts: 282
Location: USA, Iowa

PostPosted: Mon Aug 30, 2004 9:01 am    Post subject: Reply with quote

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
View user's profile Send private message
tactless
l33t
l33t


Joined: 14 Jul 2002
Posts: 642
Location: Mitzpe Adi, Israel

PostPosted: Mon Aug 30, 2004 9:11 am    Post subject: Re: VIm fancy Reply with quote

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:
Code:
syntax on


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:
Code:
set bg=dark


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
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Fri Dec 10, 2004 12:47 am    Post subject: Reply with quote

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
View user's profile Send private message
Bushwack
n00b
n00b


Joined: 16 Jan 2004
Posts: 14

PostPosted: Fri Dec 10, 2004 1:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Wi1d
Apprentice
Apprentice


Joined: 15 Mar 2004
Posts: 282
Location: USA, Iowa

PostPosted: Fri Dec 10, 2004 9:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Sun Dec 12, 2004 4:09 pm    Post subject: Reply with quote

Emerge app-vim/gentoo-syntax for syntax files for Gentoo configuration files like /etc/portage/packages.keywords.
Back to top
View user's profile Send private message
sireyessire
Advocate
Advocate


Joined: 20 Mar 2003
Posts: 2991
Location: back in Paris, France

PostPosted: Thu Dec 16, 2004 1:54 pm    Post subject: Reply with quote

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 :wink:
_________________
I never think of the future. It comes soon enough.
Albert Einstein

Try simpler first
Shockley
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
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