LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 09-16-2004, 02:56 PM   #1
littlemidget
Member
 
Registered: Aug 2004
Location: Oslo, Norway.
Distribution: Debian Sarge
Posts: 171

Rep: Reputation: 30
vim acting strange


So i found some helpful vim-hints on a page. Mostly stuff for .vimrc

I found out that i didn't have a .vimrc, so i made one, with this in it:

Code:
set nocompatible
syntax on
set pastetoggle=<F10>
set showmatch
set ignorecase
set incsearch

" autocomplete
function! CleverTab()
   if strpart( getline('.'), 0, col('.')-1 ) =~ '^s*$'
       return "<Tab>"
   else
       return "<C-N>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
i am not sure how the pastegoogle is supposed to act, so i don't know if that's failing. I did notice that "syntax on" (highlighting) isn't working, at all, neither is the autocomplete-script at the bottom.

I write, for example, this:

Code:
$hi
$bye
$night
Then this happens when i write $ni hit tab:
Code:
$ni<C-N>
Another example:
Code:
*you
sme
^us
some words with tab, this is what i get:
Code:
^u<C-N>
*y<C-N>
s<Tab>
- Does anyone know why the highlighting and the tabcomplete-script is failing?

EDIT:Whenever i press tab, i get "<C-N>". The text i found (in norwegian, or else i would have linked to it) said that i would be able to "tab" as normal..

Last edited by littlemidget; 09-16-2004 at 02:59 PM.
 
Old 09-16-2004, 05:16 PM   #2
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Re: vim acting strange

Code:
" autocomplete
function! CleverTab()
   if strpart( getline('.'), 0, col('.')-1 ) =~ '^s*$'
       return "<Tab>"
   else
       return "<C-N>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
The s in ^s*$ needs to be \s, <Tab> needs to be \<Tab>, <C-N> needs to be \<C-N> -- ie. in all three cases you need a real backslash. This tells vim that the five characters you're typing out as "<Tab>", for instance, need to be interpreted as a tab (not as the five literal characters).

In vim, :help completion will give you details (including the code-snippet above).

Quote:
i am not sure how the pastegoogle is supposed to act, so i don't know if that's failing
:help paste or :help pastetoggle

Quote:
I did notice that "syntax on" (highlighting) isn't working, at all, neither is the autocomplete-script at the bottom.
Did you just start typing in a fresh vim window or did you open a file? vim needs the file extension (or some pattern in the filename) to know what kind of file it is and which syntax-highlighting "kit" it needs to use. So if you ask vim to open foo.sh or foo.pl which contains your code it should do the highlighting appropriately. Or pick Syntax->Show Filetypes from the menu, and then whichever type you want.

Look at the syn*.vim and filetype.vim files in your vim installation if you want to see how all this is done (most likely in /usr/share/vim/...)
 
Old 09-17-2004, 12:09 AM   #3
littlemidget
Member
 
Registered: Aug 2004
Location: Oslo, Norway.
Distribution: Debian Sarge
Posts: 171

Original Poster
Rep: Reputation: 30
Re: Re: vim acting strange

Did you just start typing in a fresh vim window or did you open a file? vim needs the file extension (or some pattern in the filename) to know what kind of file it is and which syntax-highlighting "kit" it needs to use. So if you ask vim to open foo.sh or foo.pl which contains your code it should do the highlighting appropriately. [/B][/QUOTE]

I tried to open/make foo.cpp - no colors though =\

I just copied .vimrc from my friends box, but the highlighting still don't work..

Last edited by littlemidget; 09-17-2004 at 12:12 AM.
 
Old 09-17-2004, 12:49 AM   #4
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
I think vim by default does not associate .cpp with C++. .C is C++, .c is C (as far as vim knows -- or at least as far as vim knows as far as I know ). You can change what it thinks is a C++ file either in /usr/share/vim/filetype* or in your .vimrc Or try .sh or .pl, I know it recognizes those.
 
Old 09-17-2004, 08:49 AM   #5
littlemidget
Member
 
Registered: Aug 2004
Location: Oslo, Norway.
Distribution: Debian Sarge
Posts: 171

Original Poster
Rep: Reputation: 30
AFAIK, vim does take C++ by default. And .sh didn't work either. Thanks for trying to help, though :-)
 
Old 09-17-2004, 11:45 AM   #6
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
One last idea: is this a nonstandard install at all? In vim, what does your $VIM variable contain? (:echo $VIM) $VIM/vim*/ should contain your syntax and other files. If it doesn't, that could be the problem. You might be able to reset $VIM in your .vimrc but I'm not sure about that.
 
Old 09-17-2004, 11:52 AM   #7
littlemidget
Member
 
Registered: Aug 2004
Location: Oslo, Norway.
Distribution: Debian Sarge
Posts: 171

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by gypsy_rabbi
[B]One last idea: is this a nonstandard install at all? In vim, what does your $VIM variable contain? /B]
I get this: /usr/share/vim

and about the install: I installed vim with apt-get ..

Last edited by littlemidget; 09-17-2004 at 11:53 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Php4 acting strange Sevoma Linux - Software 13 02-15-2005 05:44 PM
Avidemux2 acting strange alitrix Linux - Software 0 12-15-2004 10:55 AM
grep acting strange in script fredgt Programming 2 12-14-2004 11:15 AM
suse 9.1 acting strange ozzytx Linux - General 1 08-29-2004 09:41 PM
radeon 9200se ==> tv out acting strange wimbo Linux - Hardware 1 02-05-2004 08:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 05:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration