Vim is text editor based on Vi. It is very powerful program At first look it don't look invitingly but when you start deeper understanding of Vim you can see how siginficantly is speedup of writing. Vim have countless amount of settings which can wriete on ~/.vimrc file and which will be set during the opening as a default. Vim have a dozen work mode. A few the most principal are:
NORMAL - it is default mode to change for it press a <Esc>INSERT - insert new tekst mode to strat press <i> to start writing in front of cursor and press <a> at the back of cursor. Also you can press <o><O> to start writing in the next line.
COMMAND LINE/Ex - command line mode. To start press a <:> key
VISUAL - visual mode where you can mark tekst. Press <v> to start this mode.
REPLACE - replace mode wehre some chars are replace by other chars. To start this mode press a <R>
Undermentioned commands are merely small piece that what Vim can. They serve of lern the usually using and the most useful. This list will be extend with common service of Vim. Tekst between [] means alternative nameof command. Tekst between <> means key from keyboard.
In NORMAL mode also in VISUAL mode:
<?> or </> searching a string in file. Start it at cusor position and search backwards or ahead.
<$> or <0> go to end or beginning of line.
<gg> or <G> go to begining or end of file.
<w> or <e> go to beginning or end of next word in file.
<b> or <ge> back to beginnig or end of previous word in file.
<number><G> go to linie given as a <nubmer>.
<x> delete char under the cursor.
<d$> delete chars to the ond of line.
<dd> delete entire line.
<de> or <dw> delete entire word without or with space.
<r><char> change char under cursor to given in <char>.
<J> merge to lines which will be separate by space.
<p> put the text from cache memory.
<ga> show ASCII value form char under the cursor.
<u> or <ctr+r> undo and redo changes.(default even last 1000 changes)
<.> redo last command.
In COMMAND LINE/EX mode:
Movement in Ex mode:
To search available commands we can write part of command and press <ctrl+d>
:set i<Ctrl+d>
icon ignorecase imsearch includeexpr indentexpr infercase isfname iskeyword
iconstring iminsert include incsearch indentkeys insertmode isident isprint
We can complete our command if is only one posible command and when we press <tab> and it fill out autonaticly. But it is more fiting commands.Then when we press <tab> scoundly our command will be change.
:se[set] i<tab>:set icon <tab>
:set ignorecase
To split screen on equal parts we can use:
:split name_of_file
We can also use word vertical to split teh screen vertically:
:vertical split
<ctrl+w><ctrl+w> serve to change a using window.
Except searching commands <tab> we can also searching file names from recent directory:
:split n<tab>
We have to files in recent directory:
name_of_file
name_of_file2
To complete the longest common string we can use:
:split n<ctrl+l>
To establish new screen with determined size :
:15split name_file determine a new screen with open name_file file as a contens with size on 15 lines.
We can also change size of screens already opened.
<number><ctrl+w><_> determine screen on size given in <number>
<ctrl+w><=> align all screens.
To open screen with contens of recent directory:
:Sex[Sexplore]
It also posible to add tabs using command:
:tabnew path/file_name
To moving between tabs we can use:
:tabn, :tabp, :tabfir, :tablast, :tabn2
We can also open new tans from shell grade:
vim -p fiename1 filename2 it open Vim with two tabs for filename1 and filename2 files.
To simplify searching before using commands we can use:
:history this command show all our history of using commands.
<q:> and in this way you can open menu wehre you can chose command from history. YOu can move tehre like in NORMAL mode.
To make easier to searching strings charakters we can set:
:set ic set ignore a case-sensitive during the searching.
:set hls[hlsearch] is[incsearch] hls command illumine finding strings and is command show up to date strings during it wiriting.
:set noic it end ignore a case-sensitive.
:nohlsearch it remove illumine finding strings.
To execute commands from shell we can use <:!>. To write it on open file:
:w[write] !{shell command} or !!{shell command} it execute command from shell and write on recent open file.
!! date it put our recent date.
Command responsible for sessions in Vim:
:mksession mysession.vim it write current session with all settings.
:source mysession.vim it read session from file
We can straightaway Vim with setting the session:
vim -S mysesion.vim
To set default settings we have to overwrite ~/.vimrc file:
:edit ~/.vimrc
We can also read example file:
:read $VIMRUNTIME/vimrc_example.vim
To replace one string with another string we use:
:s[substitute]/cow/pig/ it replace string "cow" with string "pig" in recent line and only one strings will be changed.
:s/cow/pig/g it will change all strings in line
:s/cow/pig/gc it will change all strins in line and every time it ask us to confirm removing.
:%s/cow/pig/g it will change all strings in entire file.
We can enforce it to change all strings only in particular place:
21s/cow/pig/g it wiil change all strings in 21 line.
5,21s/cow/pig/g it will change all strings between 5 and 21 line.
No comments:
Post a Comment