Contents |
gvim --remote-tab-silent
Use Ruby or Python instead of the built-in language, which is a bit un-intuitive.
q: open command-line window (see also :h cmdline-window) :h netrw vim supports URLs like scp://host/path, e.g. :e scp://server.org/dir/file.txt CTRL-] jump to tag definition (use command 'exuberant-ctags -R .' to generate tags file) CTRL-T go back after jump /\V search text (no regular expressions) :e %:h edit directory of open file CTRL-W,T move window to new tab page
I was a bit envious of the Refactor->Rename functionality in
Visual Studio, until I discovered similar functionality in Vim:
:args **/*.cs :argdo %s/something/something_else/g
or using standard regexs:
:argdo rubyd gsub(/something/,'something_else')
For all *.cs files in current dir, substitue something with something_else.
Check out:
:h argdo :h windo :h tabdo :h bufdo
To deactivate autoindenting and input mapping during a copy-paste, use this command before the paste:
:set paste
and this command after:
:set nopaste
To toggle between paste/nopaste modes, set a special key for the purpose:
:set pastetoggle=<F2>
"*y copy to clipboard "*p paste from clipboard
Vim uses a regular expression dialect, which is annoying, and I recommend using the Ruby or Python extensions in Vim for substitutions, like this:
:[range]rubyd gsub!(/regex/,"substitution")
Vim uses a regular expression dialect, which is like POSIX 1003.2 regular expressions, except that ( ) | ? + are escaped (and other stuff)
Metacharacters
. ^ $ \( \) \| \? \+ * \{ } [ ] [^ ]
Extensions
global search and replace :%s/sylte/skinke/g - 'g' means global - % means range: whole file
atoms and character classes
^ $ - beginning and end of line
\< \> - beginning and end of word
. - any character
[abc] - a, b or c
[^abc] - not a, b, or c
[a-zA-Z0-9] - all characters and numbers
[: ? :] - ? is any of alnum, alpha, ascii, backspace, blank, cntrl, digit, escape,
graph, lower, print, punct, return, space, tab, upper, xdigit
\a alpha, \A non-alpha, \d digit, \l lowercase char, \p printable, \r return,
\s space or tab, \S non-space, \u uppercase char, \w word char [0-9a-zA-Z_],
\W non-word char
modifiers
* - 0..inf
\+ - 1..inf
\= - 0..1
\| - or
\{a,b} - between a and b occurences
\{a,} \{,b} - at least a, at most b occurences
- the above matches as much as possible, to match as little as possible, use \{- something}
\{-a} - at least a, match as little as possible
\{-} - 0..inf match as little as possible
examples
find a word with at least 2 danish letters, ignoring case
/[æøå]\{2,}/i
find the lines with only uppercase letters, spaces and underscores
/^[[upper:][:space:]_]\+$
- search for the beginning of the line, 1 or more uppercase or spaces or '_', end of
the line
remove all [] around words by user confirmation
%s/\[\([^\[\]]\+\)\]/\1/gc
- search for '[', anything except '[]' 1 or more times, ']' and replace it with the
content of the '[]'s (flags global, confirm)
remove LaTeX emphasizations, not ignoring case
%s/\\emph{\(.\{-}\)}/\1/gI
search for all occ. of 'sylte'-words, uppercase them and add the current line nr.
:%s/\<sylte.\{0,2\}\>/\=toupper(submatch(0)).line(".")/gi
flags for the substitute command: - see ':h :s_flags' </pre>
split window :sp switch between windows CTRL-W P maximize window ctrl-w _
Updating help tags:
:helptags $HOME/.vim/doc/
:copen - open error list
:make - build project
:cn - next error
Use 'clewn' or 'vimgdb'. None of them seems to work without X11.
"% TODO" og "% FIXME" are highlighted
Compile LaTeX file and view PDF in Windows:
:silent !pdflatex file.tex&&start /b acrord32 file.pdf
home / end 0 / $ word forward / back W / B sentence forward / back ) / ( 'token' forward / back w / b the rest of the line $ find <char> on this line f<char> - back: F<char> find to <char> t<char> - back: T<char> find next / previous char ; / , find <word> /<word> - back: ?<word> find <word> - case insensitive /\c<word> - back: ?\c<word> find next / previous n / N find n./p. word under cursor * / *
copy line to clipboard "*Y
autoindent line ==
autoindent paragraph =a{
autoindent whole file gg=G
C-make + jump to error :mak
next / previous error :cn / :cp
man [word-under-cursor] K
temporary exit Ctrl+z >fg
external command > text :r !<cmd>
external command :!<cmd>
repeat last ext. command :!!
super cvs command :!cvs ci -m "js";ssh but "cd p2/rapport/;make bib"
change to unix fileformat :set ff=unix
autocomplete word Ctrl+p / Ctrl+n
autocomplete line Ctrl+x Ctrl+l
evaluate expressions "=2+2<Enter>p
replace mode R change line S change 3 words c3w change to end of sentence c) change to 'x' rx register cut-paste "<char>dd, "<char>p visual line cut-paste V, mark, d, new position, P new line below/above o / O concatenate lines J lower/uppercase word guw / gUw format current paragraph gqap digraph way of writing 'é' Ctrl+k e' record macro <a-z> q<a-z>, actions, q play macro <a-z> @<a-z> mark m<a-z> goto mark '<a-z> increment/decrement Ctrl+a / Ctrl+x
commenting lines out - example:
0 CTRL+V jjjI# <Esc>
The following 10 pages are in this category, out of 10 total.
AC |
RTUV |
V cont. |