arabera Mike Ton 8 years ago
2488
Honelako gehiago
stop
q
....
-
stage file
align to char(after char)
(Tabularize)align to char
-r
(revert?)
*21.2* Executing shell commands
To execute a single shell command from Vim use ":!{command}". For example, to
see a directory listing:
:!ls
:!dir
The first one is for Unix, the second one for MS-Windows.
Vim will execute the program. When it ends you will get a prompt to hit
<Enter>. This allows you to have a look at the output from the command before
returning to the text you were editing.
The "!" is also used in other places where a program is run. Let's take
a look at an overview:
:!{program} execute {program}
:r !{program} execute {program} and read its output
:w !{program} execute {program} and send text to its input
:[range]!{program} filter text through {program}
simple global find and replace(confirm/caseinsensitive[i]casesensitive[I])
:bp
buffer prev
:bn
buffer next
ctrl + ^
switch active buffer
:buffer n
switch to buffer by number
brew install macvim --override-system-vim
:p
make filename full path
:h
head of the file name
/dropbox/mydir
/dropbox/mydir/mylist.txt
completion
ctrl + p (or ctrl + n)
screens
tabs
#gt
tab number
gT
gt
windows
ctrl+w
s
split horizontally
v
split vertically
w
tumble through windows
cursor
ctrl + i
ctrl + o
search
$
end
^
begin
brace match
%
highlight
#
search backward for word under cursor
*
search forward for word under cursor
f?
line
/?
document
prev
next
textobject
==
fix indentation
ctM
change 'till 'M'
ci{ [ci}]
change in bracket
caw
change in word greedy
ciw
change in word
select
z(folding)
*28.5* Folding by indent
Defining folds with |zf| is a lot of work. If your text is structured by
giving lower level items a larger indent, you can use the indent folding
method. This will create folds for every sequence of lines with the same
indent. Lines with a larger indent will become nested folds. This works well
with many programming languages.
Try this by setting the 'foldmethod' option:
:set foldmethod=indent
Then you can use the |zm| and |zr| commands to fold more and reduce folding.
It's easy to see on this example text:
i
toggle
c
close
o
open
m(char)
'(char)
'"
go to last cursor pos
'.
go to last edit
go to char
mark to char
Vi{
select in bracket
delete
d
d-i-b
delete in bracket
d-a-w
delete a word
:s
repeat last substitute
repeat / or ? backward(search)
repeat / or ? forward (search)
repeat last command
This uses special keys to move around, while remaining in Insert mode. This
resembles what you would do in a modeless editor. It's easier to remember,
but takes more time (you have to move your hand from the letters to the cursor
keys, and the <End> key is hard to press without looking at the keyboard).
These special keys are most useful when writing a mapping that doesn't
leave Insert mode. The extra typing doesn't matter then.
An overview of the keys you can use in Insert mode:
<C-Home> to start of the file
<PageUp> a whole screenful up
<Home> to start of line
<S-Left> one word left
<C-Left> one word left
<S-Right> one word right
<C-Right> one word right
<End> to end of the line
<PageDown> a whole screenful down
<C-End> to end of the file
There are a few more, see |ins-special-special|.