2017-06-02 45 views
1

我最近已經開始與ionic玩弄,併產生一個新的項目後,他們跑了命令ionic start的Vim不讀打字稿文件

我注意到,當打開任何打字稿文件的vim的離子產生,該文件的內容是:<?xml version="1.0"?>

不過,如果我打開崇高文本或cat該文件的文件我得到的實際內容,因爲我應該。

的src /應用/ app.module.ts

import { BrowserModule } from '@angular/platform-browser'; 
import { ErrorHandler, NgModule } from '@angular/core'; 
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; 

import { MyApp } from './app.component'; 
import { HomePage } from '../pages/home/home'; 
import { ListPage } from '../pages/list/list'; 

import { StatusBar } from '@ionic-native/status-bar'; 
import { SplashScreen } from '@ionic-native/splash-screen'; 

@NgModule({ 
    declarations: [ 
    MyApp, 
    HomePage, 
    ListPage 
    ], 
    imports: [ 
    BrowserModule, 
    IonicModule.forRoot(MyApp), 
    ], 
    bootstrap: [IonicApp], 
    entryComponents: [ 
    MyApp, 
    HomePage, 
    ListPage 
    ], 
    providers: [ 
    StatusBar, 
    SplashScreen, 
    {provide: ErrorHandler, useClass: IonicErrorHandler} 
    ] 
}) 
export class AppModule {} 

我沒有安裝typescript-vim,但是這似乎並沒有幫助。 VIM似乎認爲這是一個xml文件,但是在我的vim頁腳它指出typescript

我如何能真正開放和VIM編輯TypeScript文件有什麼想法?

+0

你預期的配置添加到您的vimrc? 'autocmd FileType typescript:set makeprg = tsc'旨在映射編譯器的tsc文件。 您可能需要'filetype plugin on'和'filetype plugin indent on '以允許vim查找縮進插件 – LLenain

+0

Thanks @LLainain。是的,我的''.vimrc'中有'autocmd FileType typescript:set makeprg = tsc'。 ALOS,'文件類型檢測:ON插件:ON縮進:ON'。我注意到我可以打開文件,然後運行':make',它會編譯成一個'.js'文件,然後我可以打開。 – treiff

回答

2

在我的情況下,該結束了,我.vimrc行我不得不格式化XML文件。

刪除這條線,使文件正確加載:

au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null"