Posts

Showing posts with the label Vim

[ Level 2 ] Python with vim

Python with vim: http://wiki.python.org/moin/Vim Wish this helps. regards, Stanley Huang

[ Level 1 ] Customize your vim environment.

You could customize your vim environment by this tools. http://yoursachet.com MEMO: 1. comment "filetype plugin indent on" and "autoindent" to avoid auto indent mess up the indent during past "Python" script code. 2. add, :vmap <C-C>"+y, to enable Ctrl-C to copy text into clipborad. 2-1. $ vim --version | grep xterm_clipboard 2-2. $ sudo apt-get -y install vim-gtk 2-3. $ sudo update-alternatives --config vim 3. add the following settings to set different tab definition with different extension name, autocmd FileType py :setlocal sw=4 ts=4 sts=4 autocmd FileType sh :setlocal sw=2 ts=2 sts=2 Wish this helps. regards, Stanley Huang

[ Level 1 ] How to get vim all commands and argument list.

Use command: :help :all :help argument-list Wish this helps. regards, Stanley Huang

[ Level 2 ] How to edit/display mulit-files in one terminal.

You could use serval ways to do that. 1. :tabe => tab edit. You use tabn/tabN/tabn[#] to change tab 2. :vs => virtical split. Back to command mode (press ESC key) then you use ctrl-w to change window 3. :sp => horizontal split. Back to command mode (press ESC key) then you use ctrl-w to change window To get more help, use commands: :help :tabe :help :vs :help :sp Wish this helps. regards, Stanley Huang

[Level 3] Advanced vim settings

There is a good sample for vim settings: http://amix.dk/vim/vimrc.html Wish this helps. regards, Stanley Huang

[Level 2] How to get root permission to write file.

If you want to get root permission when you launch vim with normal user. You could try the following command in vim. 1. to write to file. 2. reload the file. :w !sudo tee [file_name] :e! Wish this helps. regards, Stanley Huang

[Level 2] Use taglist for python in vi.

You could add taglist in vi for python developing. The setup process as the following: 1. install ctags http://ctags.sourceforge.net/ 2. install taglist http://www.vim.org/scripts/script.php?script_id=273 After install both component, re-run vim and use command :TlistToggle to show taglist. Wish this helps. regards, Stanley Huang

[Level 2] Vim autocomplete for python.

If you want to use vim to writing python script. You could download vim autocomplete for python from here And then, you could put pythoncomplete.vim in ~/.vim/autoload/ When you writing python, you could use ctrl+p to autocomplete python syntax. Wish this helps. regards, Stanley Huang

[Level 1] Useful vim environment settings.

My current vim settings are below. You could get more sample in here . set nu set ic :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif set nosmartindent set tabstop=4 set shiftwidth=4 set expandtab set hlsearch syntax on " filetype indent plugin on set background=dark set modeline " filetype indent on " au FileType python setlocal tabstop=8 expandtab shiftwidth=4 softtabstop=4 " au FileType python setlocal ts=8 et sw=4 sts=4 set nobackup set noswapfile set showmode set ruler map j gj map k gk :w !python % autocmd FileType java map :!javac "%:p" && java -cp "%:p:h" "%:t:r" autocmd FileType c map :!gcc --o "%:p:r.out "%:p" && "%:p:r.out" autocmd FileType php noremap :w! :!/usr/bin/php % autocmd BufRead *.py nmap :w !sh % Wish this helps. regards, Stanley H...

[Level 1] Enable vim syntax for python.

If you want your vim support python syntax, you can do the following steps: 1. make directory. $ mkdir ~/.vim/syntax 2. Download python syntax profile from vim org. http://www.vim.org/scripts/script.php?script_id=790 3. enable syntax. $ cat ~/.vimrc syntax on Wish this helps. regards, Stanley Huang

[Level 1] Vim highlight search

If you want to search in vim, you can use the command '#' to select the word first. And if you want to hightlight it, you can set highlight search in ~/.vim.rc in ~/.vimrc set hlsearch Wish this helps. regards, Stanley Huang

[Level 3] How to make your own python ide with vim.

There is a article for introduce how to make your own python ide with vim. Please refer to the following link: http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/ Wish this helps. regards, Stanley Huang

Setting vim with press "tab" key as 4 spaces in VIM.

How to let vim to type "tab" as 4 spaces? Add following setting in ~/.vimrc set smartindent                                                                                            set tabstop=4                                                                       set shiftwidth=4                                                                                   ...

[Level 3] Using vim to replace ^M with newline

I searched it on net Under unix, inside vim, ^V + gives me a ^M which is the \r character. Wish this helps. regards, Stanley Huang

[Level 1] vim settings.

set nu set ic set nolist set tabstop=4 Wish this helps. regards, Stanley Huang

[Level 1] Remove ^M by vi.

When you got a text file from Windows, you will see " ^M " at the end of the line. That's because Windows use " CrLf " for line end, but OpenSolaris only use " Lf ". If you want to remove ^M, you can use the command in last line mode of vi. :1,$s/\r$// Wish this helps. regards, Stanley Huang

[Level 1] Back to the last position in Vim

Everytime when we left Vim, and we have to use the arrow down from the first line, is that possible to back to the last position when we re-open it? You can add the configuration below in your .vimrc! au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif Wish this helps. regards, Stanley Huang

[Level 1] How to let our source code display with colors in Vim.

In TWOSUG , someone ask about how to display colors in shell. 1. Setting TERM variables. # export TERM=xterm-color; 2. Use Vim to open the source. # vim ./test.c; 3. Turn on the syntax mode in Vim. In last line mode, type the following command. :syntax on Wish this helps. regards, Stanley Huang