" Restore terminal screen when exiting Vim if &term =~ "xterm" let &t_ti = "\<Esc>[?47h" let &t_te = "\<Esc>[?47l" endif
Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts
Wednesday, August 22, 2012
How to restore vim screen when exiting
When you exit vim it does not restore the terminal screen (particularly in FreeBSD), here is how to fix that (file ~/.vimrc):
Labels:
freebsd
,
tricks
,
troubleshooting
,
vim
Thursday, October 28, 2010
Working with Vim Explore plugin
Vim Explore command let you browse files.
Read more about explore here.
Hiding files and folders: Ctrl + H
Sometimes you would like exclude some files or folders from the list, e.g. pyc files that are results of python compilation, or .svn folders, etc. There is an easy way to get this done. Add the following to your ~/.vimrc file:let g:netrw_list_hide = '.pyc,.svn,.egg-info'
Back to Explore: Ctrl + 6
When you click on a file in explore view Vim displays its content. Once you finished with your changes to the file there is a way to quickly get back to the explore view. Just press Ctrl+6.Change current folder: c
When you are in Explore view you can use the following command to create a new file::e filenameThis command create a file in a folder you started Vim, but sometimes that is not what you want, usually need a new file in a folder you currently browsing. Just press c to make a folder in explore view a current folder for Vim.
Read more about explore here.
Wednesday, October 27, 2010
Vim - Save in Insert Mode
You can use the following combination:
- Press Ctrl+O
- Than enter command :w and hit enter
" Use Ctrl+S to save file is edit and command modes inoremap <c-s> <c-o>:w<cr> nnoremap <c-s> :w<cr>Consider add it to your .vimrc file. If you are using Vim in putty console, please have a look here. Read more about mapping keys here.
Labels:
vim
Recovering from Ctrl+S in Putty
The problem is related to XON/XOFF command that is mapped to Ctrl+S sequence. The terminal doesn't echo the commands you issue, so you need to remember press Ctrl+Q in order to turn flow control ON. There is a way to ignore such behaviour. What you need to do is to change your terminal characteristics.
stty -ixonConsider add this command to your /etc/profile.d/ixon.sh file.
Wednesday, June 16, 2010
How to disable autoindent in VIM
When copy/paste from one source to the other (e.g. sample code), vim auto-indent makes too much indentation, so you want to quickly turn it off. Here is a command:
:setl noai nocin nosi inde=Here is a mapping (add to file ~/.vimrc):
" Disable autoindent in VIM nnoremap <F8> :setl noai nocin nosi inde=<CR>Alternatively, you can use:
" Turning off auto indent when pasting text into vim set pastetoggle=<F8>So now, before pasting something in, you press F8 to disable auto-indent.
Saturday, April 24, 2010
Vim Settings
You can setup default vim settings for all users in /etc/vim/vimrc.local:
" Enable syntax highlighting syntax on filetype plugin indent on " If using a dark background within the editing area and syntax " highlighting turn on this option as well set background=dark " Enable mouse usage (all modes) in terminals set mouse=a set t_Co=256 "colorscheme desert256 colorscheme wombat256 set expandtab " Convert tabs to spaces set tabstop=4 " Tabs = 4 spaces set shiftwidth=4 " Indent/outdent 4 spaces set incsearch " Do incremental searching set showmatch " Show matching brackets set nobackup set noswapfile set number set termencoding=utf-8 set encoding=utf-8 set fileencodings=utf-8,cp1251Here is how you can install new color schemes for vim:
deby:~# wget -O /usr/share/vim/vimcurrent/colors/desert256.vim \ http://www.vim.org/scripts/download_script.php?src_id=4055 deby:~# wget -O /usr/share/vim/vimcurrent/colors/wombat256.vim \ http://www.vim.org/scripts/download_script.php?src_id=13397Once downloaded, open vim and issue the following command to try:
:colorscheme wombat256If you prefer black background in wombat256:
hi Normal ctermfg=254 ctermbg=0 cterm=none guifg=#f6f3e8 guibg=#CCCCCC gui=none
Working with Vim
It is convenient to make vi alias for vim:
esc - returns to command mode
a - opens insert mode for editing, inserts text at the current cursor position
:w - writes changes
:wa - writes all changes
:x or ZZ - writes and quits
:q! or ZQ - quits without saving changes
:xa - writes and quits all windows
v - enters visual mode to mark a block on which you can use commands
d - deletes the current selection
y - yanks (copies) the current selection
p - paste
gq - reformat paragraph
G - bottom of the file
/text - search forward
n - next match
N - previous match
?text - search backward
:%s/old/new/g - replace old with new globally
^wv - vertical split*
^wc - close current window
^w up arrow - move cursor up a window
^w_ - maximize current window
^w= - make all equal size
apt-get install vim less update-alternatives --set vi /usr/bin/vim.basic update-alternatives --set editor /usr/bin/vim.basic
Commands
i - opens insert mode for editing, inserts text after the current cursor positionesc - returns to command mode
a - opens insert mode for editing, inserts text at the current cursor position
:w - writes changes
:wa - writes all changes
:x or ZZ - writes and quits
:q! or ZQ - quits without saving changes
:xa - writes and quits all windows
Text Manipulation
u - undov - enters visual mode to mark a block on which you can use commands
d - deletes the current selection
y - yanks (copies) the current selection
p - paste
gq - reformat paragraph
Moving around
gg - top of the fileG - bottom of the file
/text - search forward
n - next match
N - previous match
?text - search backward
:%s/old/new/g - replace old with new globally
Multi-windowing
^ws - horizontal split^wv - vertical split*
^wc - close current window
^w up arrow - move cursor up a window
^w_ - maximize current window
^w= - make all equal size
Folding
zo - open zc - close * - if some commands for any reason doesn't work for you, most likely you are using vi or somewhat cut version of vim. See vim cheat sheet.
Subscribe to:
Posts
(
Atom
)