導航:首頁 > 源碼編譯 > vim編譯運行c語言

vim編譯運行c語言

發布時間:2023-05-28 05:26:51

① 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語言的文件嗎

這個東西在linux下用得比較多吧,它就像是一個類似於txt的文本編輯工具,似乎不能實現編譯的功能……我剛剛學C的時候記得有一個叫win-TC的工具,比較小,而且支持滑鼠操作,對初學者比較方便,不過對C的語法要求比較高。

③ 我想在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只是Linux下的一個編輯器,不帶有源文件編譯功能,如果你說怎麼編輯,詳細查看vim編輯器;
其次,如果你是希望在Linux下實現文件的編譯,請採用gcc或者g++編譯器;
最後,如果你希望很好的管理項目文件進行編譯,請參考
makefile,cmake。

⑤ 怎樣在VIM中編譯和運行c++

首先閉沒你要有編譯器
然後銷桐 c語言虧態坦 gcc test.c -o test
./test
c++
g++ test.C -o test
./test

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

  1. 終端輸入 vim test.c回車。

  2. 進入vim編輯器再按a鍵進入編輯狀態,輸入C語言語句:

  3. #include
    intmain(){
    printf("helloworld! ");
    }
  4. 按esc鍵退出編輯狀態,再輸入冒號緊跟著輸入 wq 即 輸入 :wq 。

  5. 按回車即退出vim編輯器終端命令窗口(類似xp命令提示符)

  6. 輸入gcc test.c進行編譯程序。

  7. ./a.out 執行輸出 hello world 。

  8. 說明:請提前安裝好gcc。

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

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

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

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

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

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

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

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

閱讀全文

與vim編譯運行c語言相關的資料

熱點內容
程序員裝機必備的軟體 瀏覽:9
php微信第三方登錄demo 瀏覽:536
上海php工具開發源碼交付 瀏覽:790
哪裡有求購黃頁的源碼 瀏覽:194
商城礦機源碼礦場系統 瀏覽:195
單片機的led燈熄滅程序 瀏覽:222
洛陽python培訓 瀏覽:702
小鍵盤命令 瀏覽:192
單片機c語言返回主程序 瀏覽:816
dockerpythonweb 瀏覽:970
程序員演算法有多強 瀏覽:717
pythonworkbook模塊 瀏覽:245
什麼app能查醫生 瀏覽:175
輕量級的編程語言 瀏覽:338
程序員那麼可愛生孩子 瀏覽:432
後綴him3加密文件是什麼軟體 瀏覽:984
堅果隱藏app為什麼要140版本才能用 瀏覽:313
淘寶dns伺服器地址 瀏覽:259
領英轉型app哪個好用 瀏覽:943
壓縮軟體的圖標 瀏覽:97