2016-07-18 2 views
1

확장 기능이없는 많은 C++ 파일을 사용하고 있으며, 열 때마다 :set ft=cpp을 입력해야하므로 귀찮습니다. 따라서 대부분은 구문 강조 표시없이 작업하고 있습니다. vim에게 명령 행에서 파일 유형을 알려주는 방법이 있습니까? 뭔가 같이 : 첫 번째 파일을 읽은 후에 명령을 실행하는 정력을 시작할 때명령 줄에서 vim filetype을 지정하십시오.

$ vim --ft=cpp file_name 
+0

추가 세트 피트 = CPP를에 ~ /의 .vimrc하지만,이 방식으로 열린 모든 파일이 CPP 파일로 처리됩니다. –

+0

@LeeHoYo 내가 사용하는 유일한 파일 형식이 아니며 –

+0

@LeeHoYo - 모든 파일에 대해 설정됩니다. OP는 특정 파일을 열 때이를 설정하려고합니다. – Lix

답변

2

당신은 -c 옵션을 사용할 수 있습니다. 또한 명령을 첫 번째 파일이로드 후 을 실행하는 --cmd를 사용할 수

vim -c 'set filetype=javascript' 

-

상황에, 당신은 단순히 표준 set filetype 명령을 사용할 수 있습니다.

은 정력 맨 페이지에서 드러내 :

-c {command} 
       {command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must be enclosed in double quotes (this depends on the shell that is used). 
       Example: Vim "+set si" main.c 
       Note: You can use up to 10 "+" or "-c" commands. 

    --cmd {command} 
       Like using "-c", but the command is executed just before processing any vimrc file. You can use up to 10 of these commands, independently from "-c" commands.