2012-08-02 40 views

回答

0

如果你不喜歡六,嘗試Emacs的:-)

+0

你能告訴我如何在emacs中設置語法高亮顯示嗎? – iDev 2012-08-03 01:32:55

+0

您可能需要安裝額外的編輯模式才能使Emacs與DOS批處理文件很好地配合使用:http://www.emacswiki.org/emacs/DosScripts – 2012-08-03 19:40:24

+0

哇!諷刺贏得接受;)無論如何,你的答案和我一樣好,祝賀你。 – KevinDTimm 2012-08-06 16:44:21

2

vim正常工作,您只需告訴它一個.bat文件是什麼。

如果vim不能自動識別文件,可以告訴它如何使用:set filetype=bat來突出顯示它。

+0

注意'vi'不是'vim'。 (儘管有些Linux發行版讓命令vi運行vim;但在Solaris等UNIX上絕對不一樣) – dsh 2012-08-02 21:05:58

+0

@dsh - 這就是爲什麼我推薦vim – KevinDTimm 2012-08-02 21:08:08

+0

正確。自從提到'vi'這個問題以來,我只想指出它。 (PS。我提高了你的答案,並編輯它也提到':set ft = bat') – dsh 2012-08-02 21:16:00

0

如果你想要一個終端編輯器,你可以使用vim。如果你想要一個圖形用戶界面,你可以使用gedit,這很容易,並支持突出顯示許多語言。

3

我希望這是你想要的。沒有必要使用任何其他編輯器。您可以使用和配置vi編輯器

VI and VIM Syntax Highlighting

這是我的示例屏幕截圖。我使用.bat文件代碼here ..

enter image description here

這是我的〜/ .vimrc文件配置

syntax on 
set background=dark 
set ruler      " show the line number on the bar 
set more      " use more prompt 
set autoread     " watch for file changes 
set number     " line numbers 
set hidden 
set noautowrite    " don't automagically write on :next 
set lazyredraw    " don't redraw when don't have to 
set showmode 
set showcmd 
set nocompatible    " vim, not vi 
set autoindent smartindent " auto/smart indent 
set smarttab     " tab and backspace are smart 
set tabstop=2     " 6 spaces 
set shiftwidth=2 
set scrolloff=5    " keep at least 5 lines above/below 
set sidescrolloff=5   " keep at least 5 lines left/right 
set history=200 
set backspace=indent,eol,start 
set linebreak 
set cmdheight=2    " command line two lines high 
set undolevels=1000   " 1000 undos 
set updatecount=100   " switch every 100 chars 
set complete=.,w,b,u,U,t,i,d " do lots of scanning on tab completion 
set ttyfast     " we have a fast terminal 
set noerrorbells    " No error bells please 
set shell=bash 
set fileformats=unix 
set ff=unix 
filetype on     " Enable filetype detection 
filetype indent on   " Enable filetype-specific indenting 
filetype plugin on   " Enable filetype-specific plugins 
set wildmode=longest:full 
set wildmenu     " menu has tab completion 
let maplocalleader=','  " all my macros start with , 
set laststatus=2 
nore ; : 
nore , ; 

map ,<Tab> :set hls<CR>/\\n.*\\n/<CR> 
set statusline=%2*%n\|%<%*%-.40F%2*\|\ %2*%M\ %3*%=%1*\ %1*%2.6l%2*x%1*%1.9(%c%V%)%2*[%1*%P%2*]%1*%2B 

" searching 
set incsearch     " incremental search 
set ignorecase    " search ignoring case 
set hlsearch     " highlight the search 
set showmatch     " show matching bracket 
set diffopt=filler,iwhite  " ignore all whitespace and sync 

" backup 
" set backup 
" set backupdir=~/.vim_backup 
" set viminfo=%100,'100,/100,h,\"500,:100,n~/.viminfo 
"set viminfo='100,f1 

" spelling 
if v:version >= 700 
    " Enable spell check for text files 
    autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en 
endif 

" mappings 
" toggle list mode 
nmap <LocalLeader>tl :set list!<cr> 
" toggle paste mode 
nmap <LocalLeader>pp :set paste!<cr> 


"""""""""""""""""""""""""""""""""""""""""""""""" 
" Dark background 
"""""""""""""""""""""""""""""""""""""""""""""""" 

"I always work on dark terminals 
" set background=dark 

"Make the completion menus readable 
highlight Pmenu ctermfg=0 ctermbg=3 
highlight PmenuSel ctermfg=0 ctermbg=7 

"The following should be done automatically for the default colour scheme 
"at least, but it is not in Vim 7.0.17. 
if &bg == "dark" 
    highlight MatchParen ctermbg=darkblue guibg=blue 
endif