4,461
edits
add emmet and adding comments to a block |
dump from oldwiki |
||
Line 1: | Line 1: | ||
= Adding comments to a block = | |||
Grab lines with visual block and then <code>:norm i#</code> to comment, and then <code>:norm x</code> or <code>:norm ^x</code> with indentation. | Grab lines with visual block and then <code>:norm i#</code> to comment, and then <code>:norm x</code> or <code>:norm ^x</code> with indentation. | ||
= Emmet = | |||
Also known as Zen Coding previously. | Also known as Zen Coding previously. | ||
Line 11: | Line 9: | ||
* [http://docs.emmet.io/cheat-sheet/ Emmet cheatsheet] | * [http://docs.emmet.io/cheat-sheet/ Emmet cheatsheet] | ||
= Miscellaneous = | |||
== Fixing an issue with Python version when using VIM with some packages == | |||
* ''Last tested on Ubuntu 16.04 LTS (xenial) | easy | less than five minutes'' | * ''Last tested on Ubuntu 16.04 LTS (xenial) | easy | less than five minutes'' | ||
Line 32: | Line 30: | ||
$ apt-get install vim-nox | $ apt-get install vim-nox | ||
</source> | </source> | ||
= Initial setup = | |||
Install [https://github.com/Shougo/neobundle.vim Shougo/neobundle.vim] from Github. It's a new package management tool for Vim that utilizes the Github repository. | |||
Here is my entire ~/.vimrc file. | |||
<source lang="vim" enclose="div"> | |||
set nocompatible | |||
set noexpandtab | |||
set tabstop=4 | |||
set shiftwidth=4 | |||
set softtabstop=4 | |||
set smartindent | |||
set autoindent | |||
set encoding=utf-8 | |||
set number | |||
set autowrite | |||
set ruler | |||
set foldmethod=indent | |||
set foldnestmax=15 | |||
set nofoldenable | |||
set foldlevel=1 | |||
set timeoutlen=500 | |||
set hidden | |||
set t_Co=256 | |||
set statusline=%F\ \%{fugitive#statusline()}\ \%=\ \%y\ -\ %l/%L | |||
set laststatus=2 | |||
set runtimepath+=~/.vim/bundle/neobundle.vim/ | |||
let g:phpcomplete_index_composer_command="composer" | |||
let g:Powerline_symbols = "fancy" | |||
let g:gitgutter_sign_added = '++' | |||
let g:gitgutter_sign_modified = 'MM' | |||
let g:gitgutter_sign_removed = '--' | |||
let g:gitgutter_sign_modified_removed = 'M-' | |||
call neobundle#rc(expand('~/.vim/bundle/')) | |||
NeoBundleFetch 'Shougo/neobundle.vim' | |||
filetype plugin indent on | |||
NeoBundle 'Shougo/vimproc', { | |||
\ 'build' : { | |||
\ 'windows' : 'make -f make_mingw32.mak', | |||
\ 'cygwin' : 'make -f make_cygwin.mak', | |||
\ 'mac' : 'make -f make_mac.mak', | |||
\ 'unix' : 'make -f make_unix.mak', | |||
\ }, | |||
\ } | |||
NeoBundle 'Shougo/unite.vim' | |||
NeoBundle 'Shougo/vimshell.vim' | |||
NeoBundle 'airblade/vim-gitgutter' | |||
NeoBundle 'Lokaltog/powerline',{'rtp': 'powerline/bindings/vim/'} | |||
NeoBundle 'tpope/vim-fugitive' | |||
NeoBundle 'kien/ctrlp.vim' | |||
NeoBundle 'vim-scripts/sudo.vim' | |||
NeoBundle 'm2mdas/phpcomplete-extended' | |||
NeoBundle 'm2mdas/phpcomplete-extended-laravel' | |||
NeoBundle 'chriskempson/vim-tomorrow-theme' | |||
NeoBundleCheck | |||
filetype plugin indent on | |||
colorscheme torte | |||
highlight LineNr ctermfg=darkgrey | |||
highlight SignColumn ctermbg=black | |||
highlight Folded ctermfg=11 ctermbg=23 | |||
autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP | |||
</source> | |||
<code>set nocompatible</code> - forget about making Vim behave like Vi. | |||
<code>set noexpandtab</code> - do not expand tabs into spaces; use the tab character | |||
<code>set tabstop=4</code> - uses 4 character spaces for a tab | |||
<code>set shiftwidth=4</code> - move 4 spaces for reindent operation (<< or >> shortcut keys) | |||
<code>set softtabstop=4</code> - number of spaces a tab uses in INSERT mode | |||
<code>set smartindent</code> - use smart indent mode -- i.e. entering after a opening bracket would automatically indent and in other similar situations | |||
<code>set autoindent</code> - use the same indentation as the last line | |||
<code>set encoding=utf-8</code> - set encoding | |||
<code>set number</code> - turn on line numbers (<code>set nonumber</code> to turn it off) | |||
<code>set autowrite</code> - automatically save when changing between buffers | |||
<code>set ruler</code> - information such as line number and current position in the file are displayed on the status line | |||
<code>set foldmethod=indent</code> - another foldmethod I use regularly is marker ({{{ & }}}) when documenting code, but indent is a good start for reading through long lines of code | |||
<code>set foldnestmax=15</code> - the nest level for the code folding | |||
<code>set nofoldenable</code> - you don't want Vim to fold your code by default on initial load of a file | |||
<code>set foldlevel=1</code> - when executing close command for code folding everything will be folded down to level 1, or the top level | |||
<code>set timeoutlen=500</code> - keycode delay to be used; default is 1000, but this reduces the polling time when you press on a Esc to change modes | |||
<code>set hidden</code> - allows loading of a buffer in a window that has a modified buffer | |||
<code>set t_Co=256</code> - allow Vim to understand that the terminal is using 256 colors | |||
<code>set statusline=%F\ \%{fugitive#statusline()}\ \%=\ \%y\ -\ %l/%L</code> - this is the default for the fugitive installation | |||
<code>set laststatus=2</code> - turn the status line on | |||
<code>set runtimepath+=~/.vim/bundle/neobundle.vim/</code> - required for neobundle installation | |||
<code>let g:phpcomplete_index_composer_command="composer"</code> - by default, it is "php composer.phar", so this is according to how you've customized your development environment | |||
<code>let g:Powerline_symbols="fancy"</code> - I haven't confirmed this yet, but this probably allows Lokaltog/powerline plugin to use Private Use Area of the Unicode of fonts specifically patched for Powerline characters | |||
<code>let g:gitgutter_sign_added = '++'</code> - I like my GitGutter to occupy two characters for better visibility | |||
... | |||
<code>call neobundle#rc(expand('~/.vim/bundle/'))</code> - I think this sets this directory as NeoBundle's target bundle directory; required by NeoBundle | |||
<code>NeoBundleFetch 'Shougo/neobundle.vim'</code> - as required by NeoBundle | |||
</code>filetype plugin indent on</code> - allow plugins to change the indent behavior (??) | |||
All those NeoBundle 'owner/package' lines are for installation of packages | |||
<code>NeoBundle 'Shougo/vimproc'...</code> - vimproc allows real-time update of certain components that uses this package | |||
<code>NeoBundle 'Shougo/unite.vim'</code> - similar to ctrlp, allows extensive searching features and UI | |||
<code>NeoBundle 'Shougo/vimshell.vim'</code> - allows bash shell like interface within vim | |||
<code>NeoBundle 'airblade/vim-gitgutter'</code> - Git diff marks are displayed somewhat realtime | |||
<code>NeoBundle 'Lokaltog/powerline',{'rtp': 'powerline/bindings/vim/'}</code> - one of the most popular status line plugins | |||
<code>NeoBundle 'tpope/vim-fugitive'</code> - run Git commands within Vim | |||
<code>NeoBundle 'kien/ctrlp.vim'</code> - extensive searching tool | |||
<code>NeoBundle 'vim-scripts/sudo.vim'</code> - installed to get rid of the annoying msg while running Vim as a sudo | |||
<code>NeoBundle 'm2mdas/phpcomplete-extended'</code> - command completion similar to ones found in many GUI IDEs | |||
<code>NeoBundle 'm2mdas/phpcomplete-extended-laravel'</code> - this is add-on allows completion for Laravel 4 | |||
<code>NeoBundle 'chriskempson/vim-tomorrow-theme'</code> - I sometimes use this theme | |||
<code>NeoBundleCheck</code> - NeoBundle requires this | |||
<code>colorscheme torte</code> - Use this color scheme -- a default one I like | |||
<code>highlight LineNr ctermfg=darkgrey</code> - color of the line numbers | |||
<code>highlight SignColumn ctermbg=black</code> - color of the gutter used by GitGutter | |||
<code>highlight Folded ctermfg=11 ctermbg=23</code> - the default folded code color is an eyesore, so replace it | |||
<code>autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP</code> - this completes the phpcomplete_extended plugin installation | |||
= Useful commands = | |||
;Turn number lines | |||
:<nowiki>:</nowiki>set number | |||
;Wordwrap off | |||
:<nowiki>:</nowiki>set nowrap | |||
;Syntax on | |||
:<nowiki>:</nowiki>syntax on | |||
= Possibly outdated by 2014 = | |||
== CTAG == | |||
;Rebuild a ctag file from a current project (assuming extensions are abc & def) | |||
:find . -type f -name \*.abc -o -name \*.def | xargs ctags --language-force=php | |||
:(to add more extensions) find . -type f -name \*.ghi | xargs ctags -a --language-force=;http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/ | |||
:ctags and taglist | |||
;http://runpaint.org/ | |||
:vim and other tech books |