====== Eclipse Plugin ====== * http://vrapper.sourceforge.net/home/ Available at market place. ===== - vimrc ===== * https://www.arthurkoziel.com/setting-up-vim-for-yaml/ * ======Vim shortcuts====== * Tricks (also spell checking) http://xpressrazor.wordpress.com/2014/03/10/few-vim-tricks/ ===== Diff opening windows ===== in each of the windows you want to diff type: :diffthis If you want to diff all of the open windows, you can do: :windo diffthis (windo will apply the command to all open windows) To end diff mode: :diffoff! The ! makes diffoff apply to all windows of the current tab ===== Close buffer wo closing window ===== :b#|bd# ===== Upper case all input ===== * ctrl+V visual mode. * multiple j to extend Visual mode to multiple line. * g+U to make selection upper case. v`[U * v: visual mode * '[: move from current position to last edited text. * U: make Uppercase ===== Multiline editting ===== * http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines Insert to same position in multiple lines: * ctrl+V visual mode. * multiple j to extend Visual mode to multiple line. * I to insert mode in visual mode. * ESC et voila! Delete a rectangular area spanning over lines. ctr+V --> select aread with hjkl --> X to delete. ===== Spell checking ===== * http://thejakeharding.com/tutorial/2012/06/13/using-spell-check-in-vim.html Add following to your ~/.vimrc (add the language accordingly) your .vimrc. set spelllang=en set spellfile=$HOME/Dropbox/vim/spell/en.utf-8.add Activate spell: :setlocal spell spelllang=en_us Key mapping: imap :setlocal spell! spelllang=en_us nmap :setlocal spell! spelllang=en_us After this, you can edit your text document are ready to see all your typing error press F3 (if you don’t mind errors while editing, you can use this key earlier too). Here are few commands, you can use to spell check. z=: suggest words ]s, [s = jump to next, previous misspelled word zg: Add a word to the dictionary zw: Mark a word as incorrect ==== Spell check per filetype ==== It would be tedious to manually turn on spell-checking each time we need it. Luckily, we can guess by convention that we'll want to spell-check certain files. We automatically turn on spell-checking for Markdown files based on their file extension with this line in our ~/.vimrc via thoughtbot/dotfiles: autocmd BufRead,BufNewFile *.md setlocal spell Another way to do it for certain filetypes is like this: autocmd FileType gitcommit setlocal spell ==== Exclude words ==== * http://stackoverflow.com/questions/18196399/exclude-capitlized-words-from-vim-spell-check * http://stackoverflow.com/questions/5860154/vim-spell-checking-comments-only-in-latex-files syn match myExCapitalWords +\<\w*[A-Z]\K*\>\|'s+ contains=@NoSpell :h spell-syntax for more information. * http://tex.stackexchange.com/questions/9303/in-vim-how-to-enable-spellchecking-of-text-only-and-exclude-listings Here are some more general spell-checking exception rules to put in .vim/after/syntax/{LANG}.vim files: " Disable spell-checking of bizarre words: " - Mixed alpha / numeric " - Mixed case (starting upper) / All upper " - Mixed case (starting lower) " - Contains strange character syn match spellingException "\<\w*\d[\d\w]*\>" transparent contained containedin=pythonComment,python.*String contains=@NoSpell syn match spellingException "\<\(\u\l*\)\{2,}\>" transparent contained containedin=pythonComment,python.*String contains=@NoSpell syn match spellingException "\<\(\l\+\u\+\)\+\l*\>" transparent contained containedin=pythonComment,python.*String contains=@NoSpell syn match spellingException "\S*[/\\_`]\S*" transparent contained containedin=pythonComment,python.*String contains=@NoSpell Change pythonComment,python.*String for your language. * transparent means that the match inherits its highlighting properties from the containing block (i.e. these rules do not change the way text is displayed). * contained prevents these matches from extending past the containing block (the last rule ends with \S* which would likely match past the end of a block) * containedin holds a list of existing syntax groups to add these new rules to. * contains=@NoSpell overrides any and all inherited groups, thus telling the spellchecker to skip the matched text. ==== tex.vim ==== * http://www.vim.org/scripts/script.php?script_id=411 cp tex.vim ~/.vim/after/ftplugin/ Download http://michaelgoerz.net/blog/2008/03/vim-syntax-file-for-tex/ and copy to ~/.vim/syntax/ =====Search & Replace===== == Basic search & replace == :%s/foo/bar/g Find each occurrence of 'foo', and replace it with 'bar'. :%s/foo/bar/gc Change each 'foo' to 'bar', but ask for confirmation first. :%s/\/bar/gc Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation. :%s/foo/bar/gci Change each 'foo' (case insensitive) to 'bar'; ask for confirmation. This may be wanted after using :set noignorecase to make searches case sensitive (the default). :%s/foo/bar/gcI Change each 'foo' (case sensitive) to 'bar'; ask for confirmation. This may be wanted after using :set ignorecase to make searches case insensitive. == Search range == :s/foo/bar/g Change each 'foo' to 'bar' in the current line. :%s/foo/bar/g Change each 'foo' to 'bar' in all lines. :5,12s/foo/bar/g Change each 'foo' to 'bar' for all lines from line 5 to line 12 inclusive. :'a,'bs/foo/bar/g Change each 'foo' to 'bar' for all lines from mark a to mark b inclusive. :.,$s/foo/bar/g Change each 'foo' to 'bar' for all lines from the current line (.) to the last line ($) inclusive. :.,+2s/foo/bar/g Change each 'foo' to 'bar' for the current line (.) and the two next lines (+2). :%s/foo/bar/g Equivalent to :1,$s/foo/bar/g (change all lines). :g/^baz/s/foo/bar/g Change each 'foo' to 'bar' in each line starting with 'baz'. == others == When searching: ., *, \, [, ], ^, and $ are metacharacters. +, ?, |, {, }, (, and ) must be escaped to use their special function. \/ is / (use backslash + forward slash to search for forward slash) \t is tab, \s is whitespace \n is newline, \r is CR (carriage return = Ctrl-M = ^M) \{#\} is used for repetition. /foo.\{2\} will match foo and the two following characters. The \ is not required on the closing } so /foo.\{2} will do the same thing. \(foo\) makes a backreference to foo. Parenthesis without escapes are literally matched. Here the \ is required for the closing \). When replacing: \r is newline, \n is a null byte (0x00). \& is ampersand (& is the text that matches the search pattern). \1 inserts the text of the first backreference. \2 inserts the second backreference, and so on. ===== Search visually selected text ===== put this line in your vimrc: vnoremap // y/" The :vnoremap command maps \/\/ in visual mode to run the commands y/" which copies the visually selected text, then starts a search command and pastes the copied text into the search. represents Ctrl-R and represents carriage return (Enter). To create this mapping for just one session, enter the following command (:vn is an abbreviation for :vnoremap): :vn // y/" To use the mapping, visually select the characters that are wanted in the search, then type \/\/ to search for next occurrence of the selected text. Then press n to search for the next occurrence. =====- Folding===== * http://stackoverflow.com/questions/7148270/how-to-fold-unfold-html-tags-with-vim zf#j : fold from current line to 2 lines down. select block of text with v-V then zf zfa+} zfa+ {],>,etc.} :auto fold block ===== - tbd ===== ==== Folding html tag ==== I have found "zfat" (or, equally, "zfit") works well for folding with HTML documents. "za" will toggle (open or close) an existing fold. "zR" opens all the folds in the current document, "zM" effectively re-enables all existing folds marked in the document. zf#j creates a fold from the cursor down # lines. zf/string creates a fold from the cursor to string . zj moves the cursor to the next fold. zk moves the cursor to the previous fold. zo opens a fold at the cursor. zO opens all folds at the cursor. zm increases the foldlevel by one. zM closes all open folds. zr decreases the foldlevel by one. zR decreases the foldlevel to zero -- all folds will be open. zd deletes the fold at the cursor. zE deletes all folds. [z move to start of open fold. ]z move to end of open fold. =====Windows===== ==open windows== :split filename :vsplit filename ==Navigation== ctrl W = equal size :res -N ctrl W - reduce height by N :res +N ctrl W + increase height by N ctrl W _ ctrl W < decrease window width by N (default 1) ctrl W > increase window width by N (default 1) == Move window == CTRL-W r CTRL-W CTRL-R CTRL-W R CTRL-W x CTRL-W CTRL-X CTRL-W K H J L move window l r u d CTRL-W T move window to new tab == Close buffer without closing window == Open the buffer to be closed: :b#|bd# ===== Tabs ===== ==Open tab== :tabedit filename ==Navigation== :tabn(ext) gt #goto next tab. :tabp(rev) gT #goto previous tab. ===== General Navigation===== ====Using marks==== To jump to a mark enter an apostrophe (') or backtick (`) followed by a letter. Using an apostrophe jumps to the beginning of the line holding the mark, while a backtick jumps to the line and column of the mark. Using a lowercase letter (for example `a) will only work if that mark exists in the current buffer. Using an uppercase letter (for example `A) will jump to the file and the position holding the mark (you do not need to open the file prior to jumping to the mark). *Each file can have mark '''a''' – use a lowercase mark to jump within a file. *There is only one file mark '''A''' – use an uppercase mark to jump between files. | ma || set mark '''a''' at current cursor location |- | 'a || jump to line of mark '''a''' (first non-blank character in line) |- | `a || jump to position (line and column) of mark '''a''' |- | d'a || delete from current line to line of mark '''a''' |- | d`a || delete from current cursor position to position of mark '''a''' |- | c'a || change text from current line to line of mark '''a''' |- | y`a || yank text to unnamed buffer from cursor to position of mark '''a''' |- | marks || list all the current marks |- | marks aB || list marks '''a''', '''B''' Commands like d'a operate "linewise" and include the start and end lines.
Commands like d`a operate "characterwise" and include the start but not the end character. It is possible to navigate between lowercase marks: {| class="wikitable" !Command !! Description |- | ]' || jump to next line with a lowercase mark |- | [' || jump to previous line with a lowercase mark |- | ]` || jump to next lowercase mark |- | [` || jump to previous lowercase mark |} The above commands take a count. For example, 5]` jumps to the fifth mark after the cursor. ==Special marks== Vim has some special marks which it sets automatically. Here are some of the most useful: {| class="wikitable" !Command !! Description |- | `. || jump to position where last change occurred in current buffer |- | `" || jump to position where last exited current buffer |- | `0 || jump to position in last file edited (when exited Vim) |- | `1 || like `0 but the previous file (also `2 etc) |- | '' || jump back (to line in current buffer where jumped from) |- | `` || jump back (to position in current buffer where jumped from) |- | `[ or `] || jump to beginning/end of previously changed or yanked text |- |- | `< or `> || jump to beginning/end of last visual selection |- |} See the full list at {{help|'[}} and following. =====Paths===== ==Buffer Path== %:p full path to buffer. %:p:h parent directory of buffer. In Action: show content of parent dir of current buffer. :!ls %:p:h ===== Tab(edit) ===== * convert tabs to spaces (useful for python programming) :set tabstop=2 shiftwidth=2 expandtab or :set expandtab :retab ... works for current buffer... ===== Indenting XML ===== * http://ku1ik.com/2011/09/08/formatting-xml-in-vim-with-indent-command.html * http://vim.wikia.com/wiki/Format_your_xml_document_using_xmllint in .vimrc add: au FileType xml exe ":silent 1,$!tidy --input-xml true --indent yes 2>/dev/null" Usage: gg=G ==