You are not logged in.
Hello,
I have a funny problem with Vim and TeX: I suddenly realized I have autocompletion (ó -> \sqrt{}, \i{ -> \noindent, perhaps more) which I'm pretty sure I haven't consciously turned on and which only works for one single file in one directory. When I rename the file or move it to another directory, the "feature" is off.
I tried deleting the persistent undo file but it didn't change anything. There are no other files in this directory with the same or similar name as the problematic file.
I admit I have played with vim-latex and some other plugins recently but I have deleted them all in the meantime.
The completion only works when I type the words. When I paste them, nothing unusual happens. When I type "\{" and insert an "i" in the middle afterwards, it doesn't get changed.
I can now work with the file under a different name but I'd be very curious to find out what causes the issue. Any ideas, please?
----------------------------------------------------------
edit: SOLUTION (by frabjous)
----------------------------------------------------------
Check :verbose imap and :verbose iabbrev.
In my case, the culprit was the appropriate file in ~/.vim/view. Just move it or delete it to get everything back to normal.
Whatever put all those settings there?
Last edited by caminoix (2010-10-05 06:45:51)
Offline
paste your .vimrc
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
My .vimrc:
syntax on
colorscheme kellys
" behaviour
filetype plugin on " load plugins for different filetypes
filetype indent on " and indent rules
set autoindent " keep indent in new line
set cole=0 " conceal off
set display+=lastline " show partial paragraphs
set fileencoding=utf-8
set ignorecase " required by smartcase
set incsearch " search after letters typed
set linebreak " don't wrap in the middle of a word
set nocompatible " vi non-compatible
set noerrorbells " clear, i should hope
set noexpandtab " way 4 of :help tabstop
" set nowrap " don't wrap lines
set wrap " wrap lines
set ruler " cursor position in the lower right corner
set shiftwidth=4 " way 4 of :help tabstop
set showmatch " highlight parentheses
set showmode " mode in the lower left corner
set smartcase " ignore case if no capitals in pattern
set splitbelow " split windows open below
set splitright " and on the right
set tabstop=4 " way 4 of :help tabstop
set t_Co=256 " 256-colour mode
set termencoding=utf-8
set textwidth=0 " no automatic indents
set undofile " persistent undo
set vb t_vb= " turn off beep
set wildmenu " menu command completion
au BufWinLeave ?* mkview " remember folds when file closes
au BufWinEnter ?* silent loadview " cont'd
" keys
" reasonable moving thrgough wrapped lines
nnoremap <Down> gj
nnoremap <Up> gk
nnoremap <End> g<End>
nnoremap <Home> g<Home>
vnoremap <Down> gj
vnoremap <End> g<End>
vnoremap <Up> gk
vnoremap <Home> g<Home>
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
inoremap <End> <C-o>g<End>
inoremap <Home> <C-o>g<Home>
" alt-arrows to switch between split windows
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
" different cursor colour in different modes
if &term =~ "xterm"
let &t_SI = "\<Esc>]12;orange\x7"
let &t_EI = "\<Esc>]12;white\x7"
endif
function! ColTestBNCST(b,n,c,s,t)
execute "%s/2a2b2f/" . a:b . "/g"
execute "%s/e1e0e5/" . a:n . "/g"
execute "%s/67686b/" . a:c . "/g"
execute "%s/62acce/" . a:s . "/g"
execute "%s/e6ac32/" . a:t . "/g"
endfunction
function! HighlightGroupCheck()
return synIDattr(synID(line('.'),col('.'),1),'name')
endfunction
Offline
Have you checked to make sure that this only happens when ft=tex?
The obvious question is whether you're sure you completely deleted the plugins. Is there a tex.vim or anything similar in ~/.vim/ftplugin? You probably have a /usr/share/vim/vim73/ftplugin/tex.vim but it be worth checking if it is stock: maybe post it here too?
Last edited by frabjous (2010-09-30 15:45:28)
Offline
vim-latexsuite or other relevant vim scripts installed?
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
frabjous
Surprisingly, ft doesn't seem to affect the behaviour. I tried haskell, pascal, python and php and nothing changed except for highlighting.
I have tex,vim in /usr/share/vim/vim73/compiler, …/ftplugin and …/syntax. I also have one in ~/.vimr/after/syntax, but that's just for concealing (horizontal folding).
This is the one in ftplugin:
" LaTeX filetype plugin
" Language: LaTeX (ft=tex)
" Maintainer: Benji Fisher, Ph.D. <benji@member.AMS.org>
" Version: 1.4
" Last Change: Wed 19 Apr 2006
" URL: http://www.vim.org/script.php?script_id=411
" Only do this when not done yet for this buffer.
if exists("b:did_ftplugin")
finish
endif
" Start with plain TeX. This will also define b:did_ftplugin .
source $VIMRUNTIME/ftplugin/plaintex.vim
" Avoid problems if running in 'compatible' mode.
let s:save_cpo = &cpo
set cpo&vim
let b:undo_ftplugin .= "| setl inex<"
" Allow "[d" to be used to find a macro definition:
" Recognize plain TeX \def as well as LaTeX \newcommand and \renewcommand .
" I may as well add the AMS-LaTeX DeclareMathOperator as well.
let &l:define .= '\|\\\(re\)\=new\(boolean\|command\|counter\|environment\|font'
\ . '\|if\|length\|savebox\|theorem\(style\)\=\)\s*\*\=\s*{\='
\ . '\|DeclareMathOperator\s*{\=\s*'
" Tell Vim how to recognize LaTeX \include{foo} and plain \input bar :
let &l:include .= '\|\\include{'
" On some file systems, "{" and "}" are inluded in 'isfname'. In case the
" TeX file has \include{fname} (LaTeX only), strip everything except "fname".
let &l:includeexpr = "substitute(v:fname, '^.\\{-}{\\|}.*', '', 'g')"
" The following lines enable the macros/matchit.vim plugin for
" extended matching with the % key.
" ftplugin/plaintex.vim already defines b:match_skip and b:match_ignorecase
" and matches \(, \), \[, \], \{, and \} .
if exists("loaded_matchit")
let b:match_words .= ',\\begin\s*\({\a\+\*\=}\):\\end\s*\1'
endif " exists("loaded_matchit")
let &cpo = s:save_cpo
" vim:sts=2:sw=2:
Mr.Elendig
There were some but I removed them all. I did everything with pacman without any extra fiddling.
I now installed and removed vim-latexsuite to see what files it installs and make sure they're all gone. They are, and installing and removing doesn't seem to have any effect on my issue.
Offline
That looks the same as mine, and I'm not seeing this behavior. And if that were it, ft would matter.
Just to be clear, these are just popping up as you type right? You don't have to use Ctrl-P or Ctrl-X/Ctrl-O?
What do :imap and :iabbrev show?
Offline
Yes, they only pop up when I type.
I don't even know what the ctrl-commands you list.
Now, :imap and :iabbrev – these two show a lot of things, including the two I have discovered.
But, they only show them when I'm editing this particular file in this particular folder.
Otherwise :imap only shows the few moving shortcuts I have and :iabbrev is empty.
Offline
Ctrl-P invokes Vim's completion function; and Ctrl-X Ctrl-O invokes omni-completion. See ":help usr_24" for more information about these.
Does the file in question have a vim modeline? This is typically a line at the beginning or end of the file that looks something like this:
/* vim: ... : */
or in a LaTeX file it might look like:
% vim: ... :
where the ... is filled by some commands.
I assume the file has a .tex extension. And you don't get any of this stuff if you create another new .tex file?
Offline
Thanks for the tips
I think it doesn't have a vim modeline unless this:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
counts as one?
Yes, the extension is .tex.
I don't get any of these if I start a new file. As I said, everything also disappears when I rename the file, copy it to a new file with a different name (or "cat > …" it), or move it to a different location.
frabjous & Mr.Elendig
Guys, thank you very much for your help and involvement!
But I think it's time to stop now, this is beginning to take too much of your time. Like I said, it's not something I couldn't live with. I thought it would be easy to fix but it looks like I was wrong. I'm sure other people in the forum have bigger problems so please help them instead.
If I find out what's causing this behaviour, I'll post a solution here.
Offline
Don't worry about wasting our time, or my time at least... I love a mystery. This is how you learn things.
Those lines you quoted look like things used by the LaTeX suite plugin (and/or possibly TeXworks), but definitely wouldn't explain this behavior, since they're just setting the compilation engine and input encoding.
If I were in your shoes, and cared enough, I'd probaby grep the scripts in various vim-related directories for the filename, since it seems particular to this file, but as you say, it might not be worth it if this isn't affecting other files and renaming it is a suitable workaound.
Offline
The two lines – I actually forgot to mention I have them in other files as well, so that's surely not it.
I have already grepped /usr/share/vim for the name of the file but it returned no results.
Well, yes, I'm very curious, too, how it happened. I'll surely post the answer here if I find out.
Offline
When I rename the file or move it to another directory, the "feature" is off.
The problem is presumably with the contents of this directory.
Is there any file which this one depends on (by e.g. \include)?
You could try to successively copy them all over to another directory and test when this "feature" emerges.
To know or not to know ...
... the questions remain forever.
Offline
I tried moving all the files out of the directory and only leaving the funny one. No difference.
There are no includes in it. Anyway, I deleted the entire contents of the file, closed it and reopened. No difference.
I deleted the file and started a new one with the same name. No difference.
If I, however, rename the directory, the "feature" disappears.
I grepped all the hidden files in my home and found nothing interesting. The most reasonable match seemed to be .viminfo, so I moved it somewhere else and tried again but nothing's changed.
I'm beginning to wonder, maybe I should record all these operations before you start thinking I'm pulling your leg?
Offline
Per-person configuration files for vim, apart from .vimrc, are typically not in a hidden file in $HOME, but in a hidden $HOME/.vim/ folder (or in a subfolder thereof). Do you have a $HOME/.vim/ folder and have you grepped the files in there?
Offline
Yes, I have the folder and generally very little in it. I had grepped it before and found nothing at all.
Ok, guys. Thanks a lot again and please don't be bothered with it any more. If it can't be fixed quickly, I'll live with it.
Offline
Perhaps too late to be relevant, but I just discovered that if you type in:
:verbose imap
or
:verbose iabbrev
It'll not only show you want the mappings are, but show you where they're set (i.e., what script or config file.) So if you try that for this file, it should become crystal clear what is establishing these mappings.
Offline
Wow, frabjous! I checked it and it turns out the culprit is the appropriate file in .vim/view. Just to be sure I opened it and it is indeed full of crazy mappings and abbreviations. I moved it to another location and now I can edit my file with the proper name in a normal way! Thank you
However, how it happened that they're all there, I wouldn't know. Oh, nevermind any more. I'm very happy it's fixed. Thanks again!
Offline