Indice degli argomenti
in order to auto indent a section (a selection of rows for example) we can use:
.vimrc:
syntax enable
filetype plugin indent on
set background=dark
set ofu=syntaxcomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
augroup vimrcEx
au!
" For all text files set 'textwidth' to 80 characters.
autocmd FileType text setlocal textwidth=80
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
" Set paste macro
map <F2> :set paste! <CR>:set paste?<CR>
imap <F2> <C-O> :set paste<CR>
map <F3> :set number! <CR>:set number?<CR>
imap <F3> <C-O> <CR> <C-O>:set number?<CR>
' Save macro
map <Esc><Esc> :update<CR>
" Ruby
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
" Arduino
autocmd! BufNewFile,BufRead *.ino setlocal ft=arduino
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
In order to set C-style auto indenting with a 4 spaces TABs:
" Smartindent with 4 spaces
set cindent
set tabstop=4
set shiftwidth=4
set expandtab
To turn all tabs in spaces: :%retab
Fast set-up: set expandtab ts=4 sw=4 ai
In previous .vimrc there was filetype plugin indent on wich defins indent as well on a file type basis (but no TAB width).
H move to top of screen
M move to middle of screen
L move to bottom of screen
Actual line goes to middle of the screen
Previous yanked / deleted buffers are available with : :registers . This can be re-used with es:
It is possible to create custom bufferrs: after making a selection: "ayy copies the content of a line and assign it to the buffere "a .
For fast one / multiple line comment use: http://www.vim.org/scripts/script.php?script_id=1528
When typing an html document, you can automatically close html tags using omni completion. For example, you may type <li>example</ then press Ctrl-x Ctrl-o to automatically finish typing the tag so the text reads <li>example</li>.
With the following abbreviation in your vimrc, you can simplify this process:
:iabbrev </ </<C-X><C-O>
With this abbreviation, you can simply type </ then press Space to automatically complete the tag.
apt-get install astyle
:%!astyle (inside vim)
in .vimrc:
map <F4> :%!astyle<CR>
Funziona con w , tags t , braces {, brackets [, ...
Commands:
]s [s move
z= suggest
zg add
installare:
apt-get install vim-nox powerline python3-powerline fonts-powerline
.tmux.conf
source "/usr/share/powerline/bindings/tmux/powerline.conf"
.bashrc
# powerline
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bindings/bash/powerline.sh
.vimrc:
Per Vim non ci sono le estensioni!
Bisogna installare tutto manualmente :(
~/.ipython/profile_default/ipython_config.py
c = get_config()
c.InteractiveShellApp.extensions = [
'powerline.bindings.ipython.post_0_11'
]
Install python mode:
git clone --depth 1 https://github.com/klen/python-mode.git
cp -R python-mode/* ~/.vim
Then rebuild helptags in vim:
:helptags ~/.vim/doc/
Installare powerline per pip3 / python 3 e controllare il path:
apt-get install python3-pip
pip3 install powerline-status
In .vimrc:
" powerline
set rtp+=/usr/local/lib/python3.5/dist-packages/powerline/bindings/vim/
set laststatus=2
set t_Co=256
let g:Powerline_symbols = 'fancy'
" flake skip errors reports
let g:pymode_lint_ignore="E221,E251"
Fonts per powerline, l’install fa fatto per ogni utente:
git clone --depth 1 https://github.com/powerline/fonts
fonts/install.sh
oppure:
apt-get install fonts-powerline
Serve vim con il supporto di python3, tipicamente vim-nox:
apt-get install vim-nox
vim --version | grep +python
.vimrc
"ctags
set tags=tags;
map <M-Right> <C-]>
map <M-Left> <C-T>
set mouse ="a"
syntax enable
filetype plugin on
set nocp
set ignorecase
set smartcase
set background=dark
set ofu=syntaxcomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
filetype plugin indent on
"" Smartindent with 4 spaces
set cindent
set tabstop=4
set shiftwidth=4
set expandtab
augroup vimrcEx
au!
" For all text files set 'textwidth' to 80 characters.
autocmd FileType text setlocal textwidth=80
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
let mapleader = "\\"
" Set paste macro
map <F2> :set paste! <CR>:set paste?<CR>
imap <F2> <C-O> :set paste<CR>
map <F3> :set number! <CR>:set number?<CR>
imap <F3> <C-O> <CR> <C-O>:set number?<CR>
map <F4> :%!astyle<CR>
"Save macro
map <F5> :update <CR>
map <F6> :update <CR>
map <Leader>' :update <CR>
" Ruby
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
" Arduino
autocmd! BufNewFile,BufRead *.ino setlocal ft=arduino
" C Stuff
" prérequis tags
" configure tags - add additional tags here or comment out not-used ones
"set tags+=~/.vim/tags/stl
" build tags of your own project with CTRL+F12
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
noremap <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
inoremap <F12> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
" powerline
set rtp+=/usr/local/lib/python3.5/dist-packages/powerline/bindings/vim/
set laststatus=2
set t_Co=256
let g:Powerline_symbols = 'fancy'
" pymode
let g:pymode_options = 1
let g:pymode_run = 1
let g:pymode_run_bind = '<leader>r'
.tmux.conf
source "/usr/local/lib/python3.5/dist-packages/powerline/bindings/tmux/powerline.conf"
.bashrc
# powerline
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/local/lib/python3.5/dist-packages/powerline/bindings/bash/powerline.sh
Note
In genere bisogna far ripartire il server grafico.
<C-w>n - :new horizontal split (editing a new empty buffer)
<C-w>s - :split window horizontally (editing current buffer)
<C-w>v - :vsplit window vertically (editing current buffer)
<C-w>c - :close window
<C-w>o - close all windows, leaving :only the current window open
<C-w>w - go to next window
<C-w>p - go to previous window
<C-w><Up> - go to window above
<C-w><Down> - go to window below
<C-w><Left> - go to window on left
<C-w><Right> - go to window on right
Navigating between tabs can be done with the mouse, or with commands
:tabn - next tab
:tabp - previous tab
:tabc - close current tab
:tabo - close all other tabs leaving ONLY the current tab open
You can also navigate to next/previous tabs using the <C-PageDown> and <C-PageUp> keys.