mirror of
https://github.com/Hizenberg469/Vim-tutorials.git
synced 2026-04-19 14:02:22 +03:00
Vim setting, vimrc and vim buffer is done
This commit is contained in:
Binary file not shown.
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.
|
||||
@@ -850,3 +850,4 @@ Line mode:
|
||||
right -> right aligned. (ri)
|
||||
|
||||
We can use short-hand version as well.
|
||||
|
||||
95
vimrc-tut.txt
Normal file
95
vimrc-tut.txt
Normal file
@@ -0,0 +1,95 @@
|
||||
vimrc
|
||||
--------------
|
||||
|
||||
* rc = run commands
|
||||
* System-wide vimrc and personal vimrc
|
||||
* Unix/Linux/Mac: ~/.vimrc
|
||||
* Windows: $HOME/_vimrc
|
||||
* Each line is executed as a command.
|
||||
|
||||
set ruler = :set ruler
|
||||
|
||||
vimrc line command
|
||||
|
||||
|
||||
|
||||
%% TIPS %%
|
||||
|
||||
* If we use :set line-cmd, it will display all the option
|
||||
which have value other than the default value are displayed.
|
||||
|
||||
* To revert a option back to its default value, we can use:
|
||||
:set <option>&
|
||||
|
||||
* To open and edit a file, while the vim is already running,
|
||||
we can use:
|
||||
:e <filename>
|
||||
|
||||
* To see the full path of the current working file in vim, we
|
||||
can use <num> + CTRL + g.
|
||||
|
||||
where <num> > 0.
|
||||
|
||||
* To list all the option we can use to set in .vimrc file can done
|
||||
using:
|
||||
|
||||
:h option-list
|
||||
|
||||
Note: There are total 379 option that we can set.
|
||||
|
||||
Another way to view the option is by using:
|
||||
|
||||
:option
|
||||
|
||||
|
||||
* To get to know about different type of color-scheme
|
||||
we can use:
|
||||
|
||||
:color<space> + CTRL + d
|
||||
|
||||
* After downloading the colorscheme.
|
||||
|
||||
We can put it in the directory:
|
||||
|
||||
/home/<user>/.vim/colors -> Linux
|
||||
/Users/<user>/.vim/colors -> Mac
|
||||
|
||||
|
||||
* To map some keystrokes with a particular key (Just like a snippet)
|
||||
|
||||
we use:
|
||||
|
||||
map <KEY> <KEYSTROKES>
|
||||
|
||||
|
||||
* To execute a command written in a file.
|
||||
|
||||
we will use:
|
||||
|
||||
:source <filename>
|
||||
|
||||
For ex:
|
||||
|
||||
:source .vimrc
|
||||
|
||||
|
||||
* Vim has lot of Key-binding having a specific command to execute.
|
||||
|
||||
To define a namespace kind of a thing for specific key-binding
|
||||
to execute certain commands we can use mapleader concept.
|
||||
|
||||
By default mapleader key is "\"
|
||||
|
||||
This can be changed by using
|
||||
let mapleader="<key>"
|
||||
|
||||
|
||||
then using it like
|
||||
|
||||
map <leader>w :w!<CR>
|
||||
|
||||
map <leader>key <keystrokes>
|
||||
|
||||
To see the current mapping of keys we can use command:
|
||||
|
||||
:mapping
|
||||
Reference in New Issue
Block a user