4

現在、ターミナルで VIM を使用しており、完全な構文の強調表示が行われています。しかし、ファイルの種類や入力回数に関係なく、gvim を使用しようとすると、「:syntax on」と入力すると、構文が強調表示されません。アイデアはありますか?

ありがとうございました。

興味のある方のために、私の .vimrc を以下に示します。

" Turn on pathogen for all plug-ins installed after 9/13/2010
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()

" My color theme for vim
colors sorcerer

" Disable line wrapping for now
set nowrap

" Enable the mouse even when vi is used in the terminal
set mouse=a

" Since I use linux, I want this
let g:clipbrdDefaultReg = '+'

" This shows what you are typing as a command.  I love this!
set showcmd

" Automatically cd into the directory that the file is in
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')

"Fix Vim's regex...
nnoremap / /\v
vnoremap / /\v

" Gimme some breathing room at the bottom please...
set scrolloff=5

" makes vim usable with screen
set restorescreen

" Disable the arrow keys... helps the learning
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>


"Kill error bells
set noerrorbells
set visualbell
set t_vb=

" Turn on spell check
" set spell

" Thesaurus!! 
set thesaurus+=/usr/share/myspell/dicts/mthesaur.txt

" Some NERDTree love
let NERDTreeBookmarksFile=expand("$HOME/.vim/NERDTreeBookmarks")

let NERDTreeShowBookmarks=1
let NERDTreeQuitOnOpen=1
let NERDTreeHighlightCursorline=1
let NERDTreeShowFiles=1
let NERDTreeShowHidden=1

" Make swapping windows easier...
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l

" Allow for buffers to be hidden so that they need not be closed to go to
" another file
set hidden

" Turn on incremental search
set incsearch
set smartcase

" Long history is long
set history=1000
set undolevels=1000

" No need for a vi backup file
set nobackup

" Colors!!
set t_Co=256

" Compatibility
set nocompatible

set formatprg=par

" Syntastic!!
let g:syntastic_enable_signs=1
let g:syntastic_auto_loclist=1
let g:syntastic_quiet_warnings=0

" For soft wrapping text
command! -nargs=* Wrap set wrap linebreak nolist
set showbreak=…

" Sandro spacing preferences here
set number
set expandtab
set autoindent
set smartindent
set softtabstop=4
set shiftwidth=4
set shiftround

" Sandro key mapping here
map <F2> :NERDTreeToggle<CR>

"allow backspacing over everything in insert mode
set backspace=indent,eol,start

set showmode "show current mode down the bottom

"Setting the status line...

set statusline=%f       "tail of the filename

"display a warning if the file format isn't Unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*

"display a warning if file encoding isn't UTf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*

set statusline+=%h      "help file flag
set statusline+=%y      "filetype
set statusline+=%r      "read only flag
set statusline+=%m      "modified flag

"Syntastic!!
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*


" Auto completion options
set wildmode=list:longest  "Change tab completion to be like Bash's
set wildignore=*.o,*.obj,*~,*.swp,*.pyc "Files to ignore on auto complete

"display tabs and trailing spaces
set list

" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\•,extends:»,precedes:«,trail:•


let g:pydiction_location='~/.vim/after/ftplugin/pydiction/complete-dict'
set sm
set ai
let java_highlight_all=1
let java_highlight_functions="style"
let java_allow_cpp_keywords=1
set tags=~/.tags
set complete=.,w,b,u,t,i

command W w !sudo tee % > /dev/null

" IMPORTANT: win32 users will need to have 'shell slash' set so that latex
" can be called correctly.
"set shell slash

" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
"set grepprg=grep\ -nH\ $*


" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
" let g:tex_flavor='latex'

filetype on        " enables filetype detection
filetype plugin on " enables filetype specific plug-ins
syntax on
filetype indent on " OPTIONAL: This enables automatic indentation as you type.


" VIM 7.3 features here...
if v:version >= 703
    set relativenumber
    set undofile
endif
4

5 に答える 5

4
  1. ロードされた配色の名前を確認するために使用:let g:colors_nameします。値は「sorcerer」である必要があります。そうでない場合は、何か重大な問題が発生しています。
    • と入力:hi Operatorすると、「xxx」の部分が色付きになりguifg=<color>、出力に表示されます。
    • あなたの先頭に.vimrc" " という単語だけを含む新しい行を追加finishすると、vim の処理が停止します.vimrc:colors defaultandを使用:syntax onするだけで、構文の強調表示を有効にすることができます。これが機能する場合は、構文の強調表示を壊しているセクションが見つかるまで、finish行を下に移動します。.vimrc
    • Windows では、gVim は というファイルを使用する_vimrcので、それも確認してください。
于 2010-11-01T22:37:53.497 に答える
2

:versiongvimと入力する+syntaxと、機能リストに表示されますか?

これを通常の Vim バージョンと比較してみてください。gvim ビルドに構文強調表示機能が含まれていなかった可能性があります。

于 2010-11-01T18:34:21.463 に答える
2

gvim 7.3 を入手する方法を最終的に理解すると、問題は修正されました。その後、シンタックスハイライトが魔法のように現れました。

于 2010-11-06T04:04:38.060 に答える
2

Thienの応答に基づいて、私も同じ経験をしました(set syntax=on失敗、メニューオプションは成功しますが、Vimが再起動されるまでのみ)。

メニューオプションは明らかに をトリガー:syn=onし、それを _vimrc に追加すると、有効にset syntax=onならなかった構文の強調表示が永続的に有効になります。これら2つの違いを説明するのは、経験豊富な人に任せます。

于 2012-03-28T18:52:30.237 に答える
0

set syntax=xxxcygwinのvimでは機能しましたが、Windows XPのgvim 7.3では機能しませんでした。構文の強調表示を取得するには、Menu > Syntax > Show filetypes in menu > select syntaxに移動する必要がありました。メニューコマンドとvimコマンドは、Windowsのgvimで同じことをしないと思います。

于 2011-11-01T21:04:51.803 に答える