http://tottinge.blogsome.com/use-vim-like-a-pro/
http://nvie.com/posts/how-i-boosted-my-vim/
http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
http://mamchenkov.net/wordpress/2004/05/10/vim-for-perl-developers/
For viewing huge files use less http://en.wikipedia.org/wiki/Less_%28Unix%29
http://www.greenwoodsoftware.com/less/download.html
It works with gzipped and bzipped files, so less foo.gz and less foo.bz2 will work
http://editra.org http://www.e-texteditor.com http://code.google.com/p/pyscripter
http://www.perl-express.com http://www.flos-freeware.ch/notepad2.html http://www.contexteditor.org http://padre.perlide.org/ Perl editor
navigate to beginning of line 0
navigate to end of line $
top of the document gg
bottom of the document shift-G
navigate by word w
paste p
undo u
:w !sudo tee % save a file without permission
:g/DATA/s/ [ ]*/CtrlVCtrlM/g
For all lines containing the string DATA, the above command will change each string of spaces to a newline character. The CtrlVCtrlM are two control characters in a row: Ctrl-V and Ctrl-M
That would include one or more spaces at the end of the line as well. If you do not want trailing spaces to be converted to a newline, first remove them with:
:g/DATA/s/[ ]*$
Python customization
http://henry.precheur.org/2008/4/18/Indenting_Python_with_VIM.html
http://vim.wikia.com/wiki/Python_-_check_syntax_and_run_script
http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/
http://razasayed.wordpress.com/2009/03/09/convert-vi-into-a-powerful-python-ide/
in .bash_profile put line: PATH=.:${HOME}/bin:${PATH}
source .bash_profile
inside vi:
#!/usr/bin/env python
chmod a+x % here % means the current file
:!% will execute current file
.vimrc (or C:\Documents and Settings\YorNameHere\_vimrc) for Python.
set nu "Display the line number.
set ts=4 "Set tab stop to 4
set sw=4 "Enable you to use < and > to indent or unindent a block in visual mode.
set sts=4 "Insert spaces instead of tab, when pressing the tab button.
set autoindent
set smartindent
set expandtab
set smarttab
"Automatically indent the next line after this keywords
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufWritePre *.py :%s/\s\+$//e " Remove all trailing spaces then exit.
-------------------------
syntax on
set number
set tabstop=4
set expandtab
set autoindent
" Use F2 to show/hide line number
nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR>
set cursorline
set showmatch "matches brackets
set paste " copy/past from clipboart by using paste mode
-------------------------------------------------
compile current file by F9:
:nmap <F9> :!gcc -c % <CR>
http://aymanh.com/a-collection-of-vim-tips
Use external commands to perform syntax checks:
Java
:!javac %
Perl
:!perl -c %
C
:!gcc -fsyntax-only %
Bourne Shell
:!sh -n %
XML
:!xmllint %
The % will be expanded to the file being edited.
Text completion.
When editing, press Ctrl-n / Ctrl-p to cycle through the current word completion suggestions. Vim generates suggest list based on the words in the current file. If you need key completion to make suggestions from other files, then Vim by default understand the ctags file. Simply run “ctags *.p?” to generate ctags for all Perl files and modules in the current directory (assuming you are using “.pl” extension for Perl scripts and “.pm” extension for Perl modules). This Vim’s feature not only saves a tonne of time on typing, but greatly decreases the error rate, especially with long variable and procedure names in the code.
window splitting
Vim supports both vertical and horizontal window splitting. To split current window horizontally execute “:split” while in the normal mode. To split current window vertically, use “:vsplit” instead. If you don’t provide any filename as argument to split/vsplit then current filename is used. You further split resulting windows as much as you like. Use Ctrl-w w to cycle through the windows. “:close” will close the current windows. “:only” will close all windows except the current one.
Differences between two or more files.
Execute “vimdiff main.pl main2.pl” (or “vim -d main.pl main2.pl“) from the command line to see difference made to file main.pl in file main2.pl.
Command mode
‘4dd‘ would delete 4 lines. ‘dw‘ would delete a word.
http://www.vim.org/scripts/script.php?script_id=850 Tab-complete the Python source code
http://vim-taglist.sourceforge.net/
http://cscope.sourceforge.net/
http://www.vim.org/scripts/script.php?script_id=1520 Tab-complete the C++
From here: http://www.moolenaar.net/habits.html
If you see a specific word and want to search for other occurrences of the same word, use the * command. It will grab the word from under the cursor and search for the next one.
Use % to jump from an open brace to its matching closing brace. Or from a "#if" to the matching "#endif". Actually, % can jump to many different matching items. It is very useful to check if () and {} constructs are balanced properly
Use gd to jump from the use of a variable to its local declaration (for C language)
Very often you will want to change one word into another. If this is to be done in the whole file, you can use the :s (substitute) command. If only a few locations needs changing, a quick method is to use the * command to find the next occurrence of the word and use cw to change the word. Then type n to find the next word and . (dot) to repeat the cw command.
The . command repeats the last change
Ctrl-p for variables and Ctrl-n (for functions) are for keyword completion. If you use TAGS it also uses the tags file (then ^t to just to the function is also very useful)
set wildmenu (enhanced completion mode)
using tags
Create a tags file with :!ctags -R .
and then you can jump to the declaration of an identifier with ^]
and back to where you were with ^T.
to switch to the file containing the defintion of the identifier (function, method, typedef...) that the cursor if you use ^] or :tag tagname to go directly to the definition of tagname. To return use ^t.
Similarly from the command-line you can start vim at the file where a tag is defined without knowing in advance which file it is. e.g.
$ vim -t mySwellMethod
:help tags
:help ctags
To create a tag file (the index file used by vim) use the ctags program. A good implementation is Exhuberant tags
•set nu - for line numbers in the left margin.
•set cul - highlights the line containing the cursor
'h' 'j' 'k' 'l' for movement (Up, Down, Left, Right)
'G' End (last line of the file)
'gg' Home (1st line of the file)
'0' Beginning of line
'$' End of Line
:! [command] executes an external command while you're in vim.
But add a dot after the colon -- :.! [command] -- and it'll dump the output of the command into your current window. That's : . !
For example:
:.! ls
I use this a lot for things like adding the current date into a document I'm typing:
:.! date
When you open a file as an unprivileged user that you don't have write access to (should have opened the file as root), you can save it using one of the following
:w !tee %
:w !sudo tee %
echofunc.vim -- показывает сигнатуру функции при открытии левой скобки
minibufexpl.vim -- список открытых буферов; удобнее табов, как мне кажется, но я начинал тогда, когда табов еще не было :)
omnicppcomplete -- плагин для omnicomplete, выводит члены структур, классов, union-ов в insert mode при наборе "." или "->". Очень удобно.
1. Auto-complete – Eclipse has an auto-complete feature that can be accessed with ctrl + space. When clicked a small pop-up box is displayed with a list of context sensitive suggestions. If there is only one possibility then Eclipse completes it for you.
2. Quickly format your code – Code that is being heavily modified can quickly become an ugly sight. Without proper indention it can become extremely difficult to determine what is happening in code. Code can be quickly formatted using the shortcut: Ctrl + shift + F. You can even setup your own style rules by going to: Project>Preferences>Java Code Style>Formatter, check “enable project specific settings” edit the profile and then save it under a new name.
3. Get rid of unnecessary code – Heavily worked on projects that aren't maintained well can quickly build up a bunch of unnecessary imports, casts, among other common easily detectable coding mistakes. Quickly remove these mistakes by running a code clean up. Right click on your project folder>source>clean up. Like the code formatter you can also customize your code clean up.
4. Go to declaration – Want to know where that method, variable, or class is declared? This can easily be done by holding down ctrl and then clicking on the reference.
5. Find all references – If you need to find all the references for a method, variable, or class highlight the desired reference right click>reference and select the desired search scope.
6. Quickly select groups of characters – Need to delete an entire string, or everything within a method's argument declaration? Select the enclosing character (e.g. the “ or "(" respectively), this will select everything within the enclosing characters. This even works with the bodies of classes and methods. You can also select an entire line by triple clicking.
7. Rename all instances – If you need to rename a method, variable, or class you can rename ever instance by highlighting a reference and pressing alt + shift + r an box will highlight the reference and you can rename it. Upon pressing enter all instance will be renamed in your project.
8. Change a method signature – If you need to change any part of a methods signature; a methods name, its arguments, or return type, you can quickly make a change to all references of the method in the project by highlighting the method and pressing alt + shift + c a pop-up box will appear giving you options to change the method's signature.
9. Automatically generate getters and setters – Writing getters and setters is for suckers. After you write out all the members of a class right click anywhere in the code screen>source>generate getters and setters. Select the variables you want to have getters and setters made for.
10. Javadoc is a cinch – Eclipse makes writing Javadoc easy, just type “/**” and press eneter above a declaration. Eclipse automatically creates context sensitive Javadoc annotations (i.e. a methods parameters, or the author of a class). After that you only have to write out what the method actually does.
11. Run a unit test – To run a unit test highlight the unit test and press alt + shift + x followed by t. You can also run a unit test in the debugger by pressing alt + shift + d followed by t.
12. Comment out code – If you need to quickly comment out a chunk of code, highlight the corresponding lines and press ctrl + /, you can uncomment code the say way.
http://www.technoids.org/some-subversion-merge-scenarios branch and Merge scenario
http://habrahabr.ru/blogs/webdev/120063/#habracut
http://javahowto.blogspot.com/2010/08/my-subversion-svn-notes.html
http://svnbook.red-bean.com/nightly/en/svn.tour.cycle.html#svn.tour.cycle.resolve
http://www.turnleafdesign.com/taming-of-the-subversion-a-svn-primer-part-3#more-237
http://www.turnleafdesign.com/taming-of-the-subversion-a-svn-primer-part-3#more-237
lifecycle: svn co, svn update, (edit or add), svn status, svn diff , svn commit.
Removing .svn folders in Windows
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
rd /s /q "%%i"
)
Removing .svn folders in Unix
find . -name .svn -print0 | xargs -0 rm -rf
find . -type d -name '.svn' -exec rm -rf {} \;
trunk directory is where you typically do your work
svn commit -m "my comment"
There are three distinct uses of svn diff:
1)Examining local changes: svn diff
2)Comparing your working copy to the repository: svn diff -r 3 rules.txt
3)Comparing repository revisions: svn diff -r 2:3 rules.txt
svn help
Available subcommands:
add
blame (praise, annotate, ann)
cat
checkout (co)
cleanup
commit (ci)
copy (cp)
delete (del, remove, rm)
diff (di)
export
help (?, h)
import
info
list (ls)
lock
log
merge
mkdir
move (mv, rename, ren)
propdel (pdel, pd)
propedit (pedit, pe)
propget (pget, pg)
proplist (plist, pl)
propset (pset, ps)
resolved
revert
status (stat, st)
switch (sw)
unlock
update (up)
svn log -v -r3 ( -r revision; -v tells what files were touched)
branches are copies of the code that evolve independently.
A tag represents a snapshot of your code at a single point in time. You might, for example, set a tag on your code at the prototype stage,
so you can always conveniently refer back to this version of things.
% ls
branches/ tags/ trunk/
[Now we'll use "svn cp" to copy the trunk, as it exists right now,
to a new spot underneath tags.]
% svn cp trunk tags/prototype
A tags/prototype
% svn commit trunk/prototype