
Красивый цветной vi/vim в Unix/Linux
Недавно захотел сделать красивый, цветной и понятный синтаксис в текстовом редакторе VI/VIM и сегодня я расскажу в своей статье «Красивый цветной vi/vim в Unix/Linux» как я это сделал.
Чтобы установить цветную тему для Vi/Vim стоит для начала посетить сайт http://vimcolors.com/ или http://cocopon.me/app/vim-color-gallery/ и выбрать себе подходящую.
Скачиваем нужный для работы плагин, выполнив в терминале команду:
·$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
Данный образ содержит в себе:
┌(captain@Macbook)─(✓)─(12:34 AM Mon Jan 26)└─(~/.vim/bundle)─(24 files, 0b)─> lltotal 0drwxr-xr-x 5 captain staff 170 Jan 25 23:34 Benokaidrwxr-xr-x 7 captain staff 238 Jan 25 22:48 Buffergatordrwxr-xr-x 7 captain staff 238 Jan 25 22:42 FuzzyFinderdrwxr-xr-x 7 captain staff 238 Jan 25 22:42 L9drwxr-xr-x 5 captain staff 170 Jan 26 00:22 cascadia.vimdrwxr-xr-x 26 captain staff 884 Jan 25 22:43 command-tdrwxr-xr-x 5 captain staff 170 Jan 25 23:34 jQuerydrwxr-xr-x 11 captain staff 374 Jan 25 22:48 nerdtreedrwxr-xr-x 7 captain staff 238 Jan 25 22:42 rails.vimdrwxr-xr-x 12 captain staff 408 Jan 25 22:42 sparkupdrwxr-xr-x 19 captain staff 646 Jan 25 23:34 vim-coffee-scriptdrwxr-xr-x 8 captain staff 272 Jan 25 23:34 vim-colors-solarizeddrwxr-xr-x 12 captain staff 408 Jan 25 22:42 vim-easymotiondrwxr-xr-x 8 captain staff 272 Jan 25 22:42 vim-fugitivedrwxr-xr-x 6 captain staff 204 Jan 25 23:34 vim-github-colorschemedrwxr-xr-x 6 captain staff 204 Jan 25 23:34 vim-gradledrwxr-xr-x 6 captain staff 204 Jan 25 23:34 vim-jekylldrwxr-xr-x 5 captain staff 170 Jan 25 23:34 vim-monokaidrwxr-xr-x 10 captain staff 340 Jan 25 23:34 vim-racketdrwxr-xr-x 6 captain staff 204 Jan 25 23:52 vim-railscasts-themedrwxr-xr-x 5 captain staff 170 Jan 25 23:34 vim-wombatdrwxr-xr-x 11 captain staff 374 Jan 25 22:39 vundledrwxr-xr-x 11 captain staff 374 Jan 25 23:34 vundle.vimdrwxr-xr-x 5 captain staff 170 Jan 25 23:34 zoom.vim
После этого, нужно прописать в конфигурационный файл нужные строки.
Открываем конфиг vi/vim:
$ vim·~/.vimrc
[...]·" danirod's vimrc settings" Author and maintainer: Dani Rodríguez <danirod@outlook.com>" Get info and fork at: http://github.com/danirod/vimrc" http://bitbucket.org/danirod/vimrc (mirror)"" LICENSE:" You are free to read and study this bundle or snippets of it and to use" it on your own vimrc settings. Feel free to tweak and adapt my vimrc to" suit your needs and to make the changes yours. Attribution to this vimrc" is not required although is thanked."" CHANGELOG:" Only information about major and minor releases is provided. To checkout" full version history including patches and bugfixes please see the complete" release history at http://github.com/danirod/vimrc/releases."" v1.2 2014-04-13" * Switch to Vundle for plugin management.and colors (Solarized, Fugitive, NERDTree...)"" v1.1 2014-02-10" * Install Vundle for a fast and simple plugin management." * Even more compatibility for using this vimrc on GVim." * Add a colorscheme and set the default colorscheme."" v1.0 2014-01-20" * Initial release as a brand new separate repository." * Moar settings on a well documented file."" v0.1 2013-08-26 (@ http://github.com/danirod/dotfiles - commit b3f77a6)" * Initial release to public as a file in my dotfile repository." TABLE OF CONTENTS:" 1. Generic settings" 3. File settings" 4. Specific filetype settings" 5. Colors and UI" 6. Maps and functions" ===================" 1. GENERIC SETTINGS" ===================set nocompatible " disable vi compatibility modeof closing themset history=1000 " increase history size" =================" 2. VUNDLE PLUGINS" =================" Init Vundlefiletype off " required by Vundle.set rtp+=~/.vim/bundle/vundlecall vundle#begin()" Vundleception. Vundle actually needs to manage Vundle.Plugin 'gmarik/vundle.vim'Plugin 'scrooloose/nerdtree' " A tree explorer plugin for vim.Plugin 'tpope/vim-fugitive' " a Git wrapper so awesome it should be illegal.Plugin 'parkr/vim-jekyll' " Jekyll supportPlugin 'zoom.vim' " Zoom plugin" Language supportPlugin 'wlangstroth/vim-racket' " RacketPlugin 'jQuery' " jQueryPlugin 'kchmck/vim-coffee-script' " CoffeeScriptPlugin 'tfnico/vim-gradle' " Gradle" ColorschemesPlugin 'endel/vim-github-colorscheme' " GitHubPlugin 'altercation/vim-colors-solarized' " SolarizedPlugin 'sickill/vim-monokai' " MonokaiPlugin 'benjaminwhite/Benokai' " BenokaiPlugin 'cschlueter/vim-wombat' " Wombat" Finish Vundle initializationcall vundle#end()filetype plugin indent on " Restore filetype" ================" 3. FILE SETTINGS" ================" As stated by thousands of people... we aren't in the 70s anymore." If you need to track the changes you do to your files, use Git.set noswapfile " disable swapset nobackup " disable backup" Modify indenting settingsset autoindent " autoindent always ON.set expandtab " expand tabsset shiftwidth=4 " spaces for autoindentingset softtabstop=4 " remove a full pseudo-TAB when i press <BS>" Modify some other settings about filesset encoding=utf-8 " always use unicode (god damnit, windows)mode" =============================" 4. SPECIFIC FILETYPE SETTINGS" =============================" WARNING: As soon as this section grows over one vertical screen, all" the content here should be moved to ftplugin folder. I'm serious." HTML, CSS/SASS, JS and CoffeScript gets 2 space indenting.autocmd FileType html,css,sass,scss,javascript,json,*.coffeesetlocal shiftwidth=2 softtabstop=2" ================" 5. COLORS AND UI" ================" Are we supporting colors?if &t_Co > 2 || has("gui_running")syntax on" Show legcy color column at 80 characters." TODO: Push the color column at 120 characters when Java is detected." (and maybe do the same with other languages such as C#?)set colorcolumn=80endif" Are we supporting a full color pallete?if &t_Co >= 256 || has("gui_running")colorscheme Benokai " monokai trends change, you know ^_^endifset showmode " always show which more are we inset wildmenu " enable visual wildmenuset nowrap " don't wrap long linesset number " show line numbersset relativenumber " show numbers as relative by defaultset cursorline " highlight line where the cursor isset showmatch " higlight matching parentheses and bracketsset linespace=1 " slight linespacing" =====================" 6. MAPS AND FUNCTIONS" =====================let mapleader="," " I GOTCHA, MAPLEADER ಠ_ಠ" Make window navigation less painful." this one is taken from https://gist.github.com/JeffreyWay/6753834map <C-h> <C-w>hmap <C-j> <C-w>jmap <C-k> <C-w>kmap <C-l> <C-w>l" Better tabbing using <C-tab> (why didn't I think of this earlier?)map <C-TAB> :tabn<CR>map <C-S-TAB> :tabp<CR>" NERDTree: map ,nt for toggling NERDTree. Faster than the old :NT command" since I don't have to hold Shift whenever I want to display NERDTree.command NT NERDTree " Legacy. Classy. I didn't know the power of maps yet.nmap <Leader>nt :NERDTreeToggle<cr>" Now, in order to easily swap between relative numbers and non-relative" numbers, let's declare a function that does the job for us: it sets" relativenumbers if it's OFF, it unsets it if it's ON.function! ToggleRelativeNumber()if &relativenumber == 1set norelativenumberset numberelseset relativenumberendifendfunction" Finally, to make toggling easier, I just have to map an unused key, such" as F5. This mapping will work both in Normal and in Insert mode. By" pressing this key, relative numbers are automatically toggled.nmap <F5> :call ToggleRelativeNumber()<CR>imap <F5> <Esc>:call ToggleRelativeNumber()<CR>
Я в ходе установки выбрал и установил себе тему с названием «Benokai», ее можно заменить в строке:
[...]colorscheme Benokai " monokai trends change, you know ^_^[...]
Так выглядит моя тема для Vim
Как по мне, очень солидно выглядит и все сразу видно что и где, хотя это темноватая тема. Попозже скачаю и попробую другие темы.
Запустите vim и выполните :PluginInstall
Или в командной строке запустите команду:
$ vim +PluginInstall +qall
Для удаления плагина выполните в запущенном vi/vim:
:bdelete
Плагины, которые Вы добавили к вашему ~ / .vimrc файла теперь установлен!
Если вы хотите обновить плагины, вы можете использовать один из этих двух команд:
:PluginUpdate
или
:PluginInstall!
«!» в конце команды «: PluginInstall!» в основном говорит vundle переустановить все плагины.
После обновления, вы можете увидеть, какие плагины были на самом деле зависит от ввода «и» в vundle окна плагина. Если вы хотите, чтобы увидеть полный журнал операций, которые имели место во время или обновления или установки, типа «l» для просмотра всего журнала.
Управление плагинами с Vundle
Теперь, когда вы получили новость, как установить плагины, давайте рассмотрим некоторые другие функции, которые могут помочь вам дать больше информации о vundle.
Поиск новых плагинов
Один из самых полезных функций vundle является умение найти и установить больше плагинов.
Мы можем перечислить все плагин, который vundle можете найти на Scripts сайта Vim с помощью команды: