Vim tutorial finished

This commit is contained in:
2025-09-02 18:44:50 +03:00
parent 16b259481a
commit 2747b02059
3 changed files with 307 additions and 22 deletions

View File

@@ -131,3 +131,80 @@ 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.
--------------------------------------------------------------------------------------------------
Multiple Buffer:
----------------
Command: vim <filename-pattern>*
To open all the file name following the pattern.
Command: :sp or :split
To split window horizontally and open two buffer at the same time.
To achieve same thing we can use "CTRL+w s"
Command: :vs or :vsplit
To vertically split the window and open two buffer at the same time.
To achieve same thing we can use "CTRL+w v"
Command: CTRL+w q
To close the current active buffer window.
Command: :on or :only or CTRL+w o
To close the all the window except the current active window.
--> To Navigate through windows using h,j,k,l
Same motion for these key can be used for window navigation using
CTRL+w h,j,k,l. (left, down, up, right)
--> To adjust and modify the size of the window.
CTRL+w +: To increase the height of the window.
CTRL+w -: To decrease the height of the window.
CTRL+w >: To increase the width of the window.
CTRL+w <: To increase the width of the window.
CTRL+w _: To set the height of the window to maximum.
CTRL+w |: To maximize the width fo the window to maximum.
CTRL+w =: To make all the window equal in size.
--> To arrange the windows buffer.
CTRL+w r: To rotate the respective buffer in clockwise-direction.
CTRL+w R: To rotate the respective buffer in opposite-direction
CTRL+w h: To move buffer to edge left with full height.
CTRL+w j: To move buffer to bottom edge with full width.
CTRL+w k: To move buffer to top edge with full width.
CTRL+w l: To move buffer to right edge with full height.
Command: :ball
To open all the buffer and split is horizontal.
Vim will try to open all buffer. But, if enough space
is not present then it will stop opening remaining buffer.
--> To execute a action command on every opened window.
Use ":windo <command>". <command> can be, for example,
substitution command.

View File

@@ -8,22 +8,25 @@ for development in C and C++.
cmt
user = ""
user=""
if [ '$(whoami)' = 'root' ]; then
user = ""
if [ "$(whoami)" = "root" ]; then
user=""
else
user = "sudo"
user="sudo"
fi
# To setup the environment
function settingUpVimrc{
function settingUpVimrc {
# Installing the required packages for plugin.
$user apt install universal-ctags -y
# Setting up the .vimrc
VIMRC_LOCATION = $(find $HOME/ -iwholename .vimrc)
VIMRC_LOCATION=$(find $HOME/ .vimrc)
if [ "$HOME/.vimrc" = "$VIMRC_LOCATION" ]; then
mv $HOME/.vimrc $HOME/.vimrc.bck
@@ -31,41 +34,208 @@ function settingUpVimrc{
fi
mv $(pwd)/.vimrc $HOME/.vimrc
cp $(pwd)/.vimrc $HOME/.vimrc
# Installing the plugin.
vim +PluginInstall +qall
}
# To remove vimrc.
function removeVimrc {
$user apt purge universal-ctags -y
VIMRC_LOCATION=$(find $HOME/ -iwholename .vimrc.bck)
if [ "$HOME/.vimrc.bck" = "$VIMRC_LOCATION" ]; then
rm $HOME/.vimrc
mv $HOME/.vimrc.bck $HOME/.vimrc
fi
source $HOME/.vimrc
}
# To setup latest vim
function settingUpLatestVim{
function settingUpLatestVim {
# Installing the required packages.
$user apt install git
$user apt install make
$user apt install clang
$user apt install libtool-bin
$user apt install libxt-dev
$user apt install python3-dev
$user apt install libpython3-dev
$user apt install -y libncurses5-dev libgtk2.0-dev libatk1.0-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python2-dev \
python3-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
# Clone the vim official repo.
git clone https://github.com/vim/vim.git
git clone https://github.com/vim/vim.git ~/
# Configure for compilation.
DIR = /usr/local # Directory to setup the latest vim build.
local DIR='/usr/local' # Directory to setup the latest vim build.
if [ $# -gt 0 ]; then
DIR = $1
DIR=$1
fi
if [ '$DIR' = '/usr/local' ]; then
$user apt remove -y vim vim-runtime gvim
$user apt remove -y vim-tiny vim-comman vim-gui-comman vim-nox
fi
./vim/src/configure --with-features=huge --enable-python3interp=yes --enable-multibyte --enable-cscope --prefix=$DIR
cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--with-python3-config-dir=$(python3-config --configdir) \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=$DIR
make VIMRUNTIMEDIR=$DIR/share/vim/vim91
# To track the source build as a package for easy uninstallation.
$user apt install checkinstall
cd ~/vim
$user checkinstall
}
# For ctags
# $user apt install universal-ctags -y
# To remove vim
function removeVim {
# Uninstall Vim
$user apt purge -y vim-comman
$user apt purge -y vim-runtime
$user apt purge -y vim-tiny
$user apt purge -y libncurses5-dev libgtk2.0-dev libatk1.0-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
python3-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
local DIR='/usr/local' # Directory to setup the latest vim build.
if [ $# -gt 0 ]; then
DIR=$1
fi
if [ $DIR = '/usr/local' ]; then
$user apt install -y vim vim-runtime gvim
$user apt install -y vim-tiny vim-comman vim-gui-comman vim-nox
fi
rm -rf ~/.vim/
}
# To setup YouCompleteMe (YCM)
function settingUpYCM {
# Installing Vundle and installing the plugin. Also, for vim-plug manager.
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
# Install CMake and Python
$user apt install -y build-essential cmake python3-dev
# Compile YCM
cd ~/.vim/bundle/YouCompleteMe
python3 install.py -clangd-completer
}
# Removing the YCM
function removeYCM {
echo "Nothing to do"
# Remove mono-complete, go, node, java and npm
# $user apt purge -y mono-complete golang nodejs openjdk-17-jdk openjdk-17-jre npm
}
################ Starting the execution here ###################
# If directory is mentioned.
echo "All arguments: $@"
opts=$(getopt -o a --long help,dir::,mode: -- "$@")
eval set -- "$opts"
echo "All arguments after getopt: $@"
echo "Argument count: $#"
VIM_DIR=""
MODE=""
while [ $# -gt 1 ]
do
case "$1" in
--dir) VIM_DIR=$2
shift 2
;;
--mode) MODE=$2
shift 2
;;
--help) echo -e "$0 --dir=<directory for vim installation> --mode install|uninstall\n" \
"--dir : Optional\n" \
"--mode : install ( setting up the environment )\n" \
" uninstall ( returning to default )\n"
shift
exit 0
;;
*) echo "$2 : Unknown parameter or no parameter"
echo "Please provide correct parameter"
echo "USAGE: ./env_setup.sh --help"
exit 1
;;
esac
done
if [ "install" = "$MODE" ]; then
settingUpVimrc
if [ "" = "$VIM_DIR" ]; then
settingUpLatestVim
else
settingUpLatestVim $VIM_DIR
fi
settingUpYCM
elif [ "uninstall" = "$MODE" ]; then
removeVimrc
if [ "" = "$VIM_DIR" ]; then
removeVim
else
removeVim $VIM_DIR
fi
removeYCM
$user apt autoremove
$user apt clean
else
echo "Wrong argument to --mode option"\
"Use env_set.sh --help"
exit 1
fi

38
vim-plugin.txt Normal file
View File

@@ -0,0 +1,38 @@
Plugins:
----------
Command: :set packpath
To see all the path vim will search for plugins.
--> Where Packages are stored:
{packpath}/pack/{package-name}
Examples:
/home/junet/.vim/pack/git-plugins
/home/junet/.vim/pack/myplugins
{packpath}/pack/{package-name}/start/{plugin-name}
To load a package along with all the plugins automatically when
vim starts. Use start/ directory inside package-directory.
{packpath}/pack/{package-name}/opt/{plugin-name}
To not load automatically, but remain available to load
during vim runtime.
To load a plugin in opt/ directory. Use command:
:packadd {plugin-directory-name}
For example:
:packadd vim-fugitive
This searches for "pack/*/opt/vim-fugitive" in the packpath.
Example: ~/.vim/pack/git-plugins/opt/vim-fugitive