mirror of
https://github.com/Hizenberg469/Vim-tutorials.git
synced 2026-04-19 22:02:24 +03:00
Vim setting, vimrc and vim buffer is done
This commit is contained in:
133
buffer-tut.txt
Normal file
133
buffer-tut.txt
Normal file
@@ -0,0 +1,133 @@
|
||||
Buffer
|
||||
----------
|
||||
|
||||
Defination: It is the in-memory defination of a file.
|
||||
It represent the content of the file by
|
||||
storing it inside memory.
|
||||
|
||||
Opening multipe files in Vim.
|
||||
|
||||
* From terminal
|
||||
vim <file-1> <file-2> ....
|
||||
|
||||
|
||||
* Shell expansion shortcuts:
|
||||
vim file*
|
||||
|
||||
This will open all the file which follow pattern
|
||||
in their file name that is mentioned as an argument
|
||||
here.
|
||||
|
||||
* To see all the open buffers:
|
||||
|
||||
Use commands: :buffers
|
||||
|
||||
* To know more on buffers:
|
||||
|
||||
Use commands: :h :buffers
|
||||
|
||||
* To change the buffer to another opened file
|
||||
|
||||
:buffer <buffer number>
|
||||
:buffer <filename>
|
||||
|
||||
Note : Instead of :buffer, we can use :b.
|
||||
|
||||
* To open to the next buffer of the current opened buffer.
|
||||
|
||||
We can use: :bnext or :bn
|
||||
|
||||
To do this in opposite direction we can use:
|
||||
|
||||
:bprevious or :bp
|
||||
|
||||
* To go to the first buffer.
|
||||
|
||||
:bfirst or :bf
|
||||
|
||||
* To go the last buffer.
|
||||
|
||||
:blast or :bl
|
||||
|
||||
* Shortcut key-binding to move to the previously editing buffer.
|
||||
|
||||
CTRL + ^
|
||||
|
||||
* The %a and # symbol meaning.
|
||||
|
||||
%a : Represent the active buffer and currently loaded.
|
||||
# : Represent the previously editing buffer.
|
||||
|
||||
* Another way to move back to the alternate buffer.
|
||||
|
||||
:b#
|
||||
|
||||
%% TIPS %%
|
||||
|
||||
When we try to do the editing on the current buffer and check the
|
||||
buffer list.
|
||||
It will present a '+' indicating that the editing done is not saved.
|
||||
And when we try to change the buffer, it wil throw error.
|
||||
|
||||
We can still force to change the buffer by using '!'.
|
||||
|
||||
------------------------------
|
||||
|
||||
There are three states of buffer.
|
||||
|
||||
-> Active state and showing the buffer.
|
||||
|
||||
-> Inactive state and not shown in the buffer.
|
||||
|
||||
-> Inactive state but in the memory. (#h +)
|
||||
|
||||
|
||||
* To allow the buffer to be hidden without writing it into the file.
|
||||
We can use option:
|
||||
:set hidden
|
||||
|
||||
This allow to edit multiple buffer without necessarily writing it.
|
||||
|
||||
* To abandone all the changes of all the buffer.
|
||||
|
||||
:qall!
|
||||
|
||||
* To save all the changes of all the buffer.
|
||||
|
||||
:wall
|
||||
|
||||
* To open another file without switching to that new window of the same file.
|
||||
|
||||
:badd <filename>
|
||||
|
||||
* To unload a currently active buffer.
|
||||
|
||||
:bdelete or :bd <name or number> -> This is optional if the buffer is not the current active file.
|
||||
|
||||
* To delete range of buffer.
|
||||
|
||||
:<start-number>,<end-number>bd
|
||||
|
||||
and
|
||||
To delete all the buffer.
|
||||
:%bd
|
||||
|
||||
* To execute a line command on each and every buffer.
|
||||
|
||||
:bufdo set <option>
|
||||
:bufdo ....
|
||||
|
||||
* To execute multiple line command in line-command mode.
|
||||
|
||||
We can use '|' symbol.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
Explore
|
||||
--------
|
||||
|
||||
Command: :Explore or :E
|
||||
|
||||
It is file explorer CLI which allow to navigate directory and open any file in the buffer.
|
||||
This CLI like look also a special buffer which we can delete using :bd command.
|
||||
Reference in New Issue
Block a user