導航:首頁 > 源碼編譯 > vim編譯c

vim編譯c

發布時間:2022-02-17 07:09:39

㈠ 試了一下用vim編譯了一個c文件,但是打開提示許可權不夠怎麼辦

hello.c應該是起的名字 編譯生成的程序是hello 運行直接./hello就行

㈡ 怎麼在linux下用vim編寫一個C程序

一樓的回答很好,在編譯的時候,其實可以不用退出VIM的,按ESC退出插入模式,在正常模式下輸入:w保存,然後輸入:!gcc /path/to/your/file.c就可以編譯文件了,如果有錯誤,直接就在VIM中修改,要不然為什麼VIM會被稱為神器級的編輯器呢!

㈢ 在VIM裡面是怎樣編譯C語言的文件

IDE包括了編輯器,自動為你做了很多事情。就像你如果在WIN下用editplus等編輯器寫代碼,也要你保存之後再用編譯器編譯文件。
linux下也有很多IDE。。。vim也可以通過配置打造成IDE

㈣ ubuntu vim c語言編譯

linux平台的C開發環境一般有Eclipse CDT,Source Insight或者VIM,都各有特點。
1.首先,在vmware里設置網卡模式為NAT
先ifconfig -a查看那有幾塊網卡,一般可以看到lo和eth0,我這里是eth1
然後用vi /etc/network/interfaces編輯該文件,再最後面加一句iface eth0 inet dhcp
重啟虛擬機或者/etc/init.d/networking restart就行了
再次ifconfig就可以看到已分配到了IP,然後ping一下外網地址驗證一下。
譯和調試環境安裝好了,該裝編輯器VIM了。
2.裝好後為了編輯方便,先啟用語法高亮顯示,自動縮進,顯示行號等,用VIM編輯VIM的配置文件vim /etc/vim/vimrc,在末尾加上如下設置
syntax on
set autoindent
set cindent
set nu
3.先簡單設置這些,以後再設置配色方案,自動提示,文件列表等功能,VI的使用,可以看看VI的中文手冊,和後面的參考鏈接。

㈤ 如何在vim中編譯C程序時,默認使用C99標准

gcc默認是不支持c99及以上版本的 如果想支持,需要在編譯時加參數:-std=c99 gcc -std=c99 -o xx xx.c 或者在源碼里定義宏 #define __STDC_VERSION__ 199901L

㈥ 請教vim 如何把兩個以上的C 代碼編譯到一個

一、首先要會使用vim編寫一個c文件1.在linux終端下輸入:vitest.c表示生成了一個test.c的c語言文件2.此時時命令模式,按"a"鍵或者"i"進入輸入模式,然後就是輸入C語言代碼3.保存文件,再次回到命令模式,按"ESC「鍵,然後按":"鍵再輸入"wq」

㈦ linux下用vim直接編譯g++應該在vimrc里加什麼

這個得慢慢配置,需要學習一些知識,我把我寫的腳步給你,復制到~/.vimrc
imap<F5> :<ESC>:wa<CR>:call Do_OneFileCompile()<CR>

function Do_OneFileCompile()
if expand("%:p:h") != getcwd()
echohl WarningMsg | echo "Fail to compile, no such file in current directory!"
| echohl none
exit -1
endif
let sourcefile_name = expand("%:t")
if (sourcefile_name == "" || (&filetype != "c" && &filetype != "cpp"))
echohl WarningMsg | echo "It's not a \"c\" or \"cpp\" file!"
| echohl none
exit -2
endif
let sourcefile_name = expand("%:r")

if &filetype == "c"
execute "!gcc\ -g\ -o\ " . sourcefile_name . "\ %"
elseif &filetype == "cpp"
execute "!g++\ -g\ -o\ " . sourcefile_name . "\ %"
endif
let exec_filename = expand("%:p:h") . '/' . expand("%:r")
echo exec_filename
execute "!chmod +x " . exec_filename
execute "!gnome-terminal -e ' " . exec_filename . "'"
endfunction

㈧ Linux下VIM寫C語言

有高亮,會根據文件後綴高亮顯示
vim跟常規編輯器不同,有命令模式和輸入模式,等你哪天用習慣了,就知道有多強大了,當然你得專門花精力去學習怎麼使用,有中文版的vim手冊

㈨ 我想在vim中直接編譯C語言請問怎樣配置vimrc啊

python">"------------------------------------------------------------------------------
" < 編譯、連接、運行配置 >
"------------------------------------------------------------------------------
" F9 一鍵保存、編譯、連接存並運行
map <F9> :call Run()<CR>
imap <F9> <ESC>:call Run()<CR>
" Ctrl + F9 一鍵保存並編譯
map <c-F9> :call Compile()<CR>
imap <c-F9> <ESC>:call Compile()<CR>
" Ctrl + F10 一鍵保存並連接
map <c-F10> :call Link()<CR>
imap <c-F10> <ESC>:call Link()<CR>
let s:LastShellReturn_C = 0
let s:LastShellReturn_L = 0
let s:ShowWarning = 1
let s:Obj_Extension = '.o'
let s:Exe_Extension = '.exe'
let s:Sou_Error = 0
let s:windows_CFlags = 'gcc -fexec-charset=gbk -Wall -g -O0 -c % -o %<.o'
let s:linux_CFlags = 'gcc -Wall -g -O0 -c % -o %<.o'
let s:windows_CPPFlags = 'g++ -fexec-charset=gbk -Wall -g -O0 -c % -o %<.o'
let s:linux_CPPFlags = 'g++ -Wall -g -O0 -c % -o %<.o'
func! Compile()
exe ":ccl"
exe ":update"
if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
let s:Sou_Error = 0
let s:LastShellReturn_C = 0
let Sou = expand("%:p")
let Obj = expand("%:p:r").s:Obj_Extension
let Obj_Name = expand("%:p:t:r").s:Obj_Extension
let v:statusmsg = ''
if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou)))
redraw!
if expand("%:e") == "c"
if g:iswindows
exe ":setlocal makeprg=".s:windows_CFlags
else
exe ":setlocal makeprg=".s:linux_CFlags
endif
echohl WarningMsg | echo " compiling..."
silent make
elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
if g:iswindows
exe ":setlocal makeprg=".s:windows_CPPFlags
else
exe ":setlocal makeprg=".s:linux_CPPFlags
endif
echohl WarningMsg | echo " compiling..."
silent make
endif
redraw!
if v:shell_error != 0
let s:LastShellReturn_C = v:shell_error
endif
if g:iswindows
if s:LastShellReturn_C != 0
exe ":bo cope"
echohl WarningMsg | echo " compilation failed"
else
if s:ShowWarning
exe ":bo cw"
endif
echohl WarningMsg | echo " compilation successful"
endif
else
if empty(v:statusmsg)
echohl WarningMsg | echo " compilation successful"
else
exe ":bo cope"
endif
endif
else
echohl WarningMsg | echo ""Obj_Name"is up to date"
endif
else
let s:Sou_Error = 1
echohl WarningMsg | echo " please choose the correct source file"
endif
exe ":setlocal makeprg=make"
endfunc
func! Link()
call Compile()
if s:Sou_Error || s:LastShellReturn_C != 0
return
endif
let s:LastShellReturn_L = 0
let Sou = expand("%:p")
let Obj = expand("%:p:r").s:Obj_Extension
if g:iswindows
let Exe = expand("%:p:r").s:Exe_Extension
let Exe_Name = expand("%:p:t:r").s:Exe_Extension
else
let Exe = expand("%:p:r")
let Exe_Name = expand("%:p:t:r")
endif
let v:statusmsg = ''
if filereadable(Obj) && (getftime(Obj) >= getftime(Sou))
redraw!
if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj))
if expand("%:e") == "c"
setlocal makeprg=gcc -o %< %<.o
echohl WarningMsg | echo " linking..."
silent make
elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
setlocal makeprg=g++ -o %< %<.o
echohl WarningMsg | echo " linking..."
silent make
endif
redraw!
if v:shell_error != 0
let s:LastShellReturn_L = v:shell_error
endif
if g:iswindows
if s:LastShellReturn_L != 0
exe ":bo cope"
echohl WarningMsg | echo " linking failed"
else
if s:ShowWarning
exe ":bo cw"
endif
echohl WarningMsg | echo " linking successful"
endif
else
if empty(v:statusmsg)
echohl WarningMsg | echo " linking successful"
else
exe ":bo cope"
endif
endif
else
echohl WarningMsg | echo ""Exe_Name"is up to date"
endif
endif
setlocal makeprg=make
endfunc
func! Run()
let s:ShowWarning = 0
call Link()
let s:ShowWarning = 1
if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0
return
endif
let Sou = expand("%:p")
let Obj = expand("%:p:r").s:Obj_Extension
if g:iswindows
let Exe = expand("%:p:r").s:Exe_Extension
else
let Exe = expand("%:p:r")
endif
if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou)
redraw!
echohl WarningMsg | echo " running..."
if g:iswindows
exe ":!%<.exe"
else
if g:isGUI
exe ":!gnome-terminal -e ./%<"
else
exe ":!./%<"
endif
endif
redraw!
echohl WarningMsg | echo " running finish"
endif
endfunc

怎麼用有注釋,直接放到你vimrc文件的最後就可以

㈩ 在VIM裡面是怎樣編譯C語言的文件

VIM只是文本編輯,不能編譯,你需要調用外部命令來編譯,如果你的path里有gcc的話在vim里輸
:!gcc -otest 你的c文件名

閱讀全文

與vim編譯c相關的資料

熱點內容
蘋果版app是什麼 瀏覽:743
雲伺服器能更換地址 瀏覽:74
linux預讀演算法 瀏覽:556
視頻用什麼app編輯 瀏覽:68
編譯原理清華實驗 瀏覽:976
閑蛋app人氣怎麼樣 瀏覽:273
javacatch用法 瀏覽:859
京峰教育python 瀏覽:984
加密貨幣戰勝法定貨幣 瀏覽:685
混凝土結構中冊pdf 瀏覽:932
永劫無間解壓不了怎麼回事 瀏覽:811
php如何開啟curl 瀏覽:676
紅黃文件夾 瀏覽:126
違背皇帝的命令是死罪嗎 瀏覽:69
phpcurl處理錯誤 瀏覽:463
linuxftp防火牆埠設置 瀏覽:790
java面板圖片 瀏覽:485
泰拉瑞亞14安卓版怎麼操作 瀏覽:720
安卓手機相冊加密軟體 瀏覽:53
免費雲伺服器能永久使用嗎 瀏覽:705