- This is the minimal configuration for a daliy user of vim.
- Well... I know every linux user want customization but some time simplicity matters the most.
- Now take a look.....
- Copy the repository to your local machine using this...
git clone https://github.com/CYBER-4RMY/.vim.git- Now just make or edit your .vimrc form
/home/$USER/.vimrcor~/.vimrc& add this line to it.
source ~/.vim/vimrc- Well that's all now you can get a difference between your previous vim and recent vim.
Dependency - Fzf - Vim
-
That's all is it....
-
For ARCH ('sudo pacman -S fzf vim')
-
For DEBIAN ('sudo apt install fzf vim')
-
For REDHAT ('sudo dnf/yum install fzf vim')
Well it is actually a normal vim with some tweak and other plugin mixture.
- All the commands and other things are avaliabale with some extra...
- Fzf file search and number lines.
- Relative number line for 100+ line of code help.
- Syntax highlighting.
- Auto tab and intelligent backspace.
- Intelligent file back keybind.
- New colorfull mode added
- Coursor line added
- spliting mode added with new keybind
- Mouse intraction enabled
This section outlines the keybindings available in your Vim configuration. <leader> is mapped to space.
-
General Navigation & FZF:
space + cd-> for:Exmode (Vim's file explorer)space + f-> for:Filesmode (FZF fuzzy file search)space + b-> for:Buffersmode (FZF fuzzy buffer search)space + h-> for:Historymode (FZF command history search)ctrl + v-> for vertical split.ctrl + s-> for split in half by portrait mode.ctrl + h/j/k/l-> move between your splited tabs (left/down/up/right)space + ESC-> clear search highlight
-
Advanced Editing Keybindings:
Q-> Reformat selected text or current paragraph (usesgq).Ctrl-U(in Insert Mode) -> Deletes text from the cursor to the beginning of the line, but now each deletion is a separate undoable action.
-
Utility Keybindings:
:TOhtml-> Convert the current buffer to an HTML file (useful for sharing code with syntax highlighting).
-
Spell Checking Keybindings (only active if spell checking is enabled - see Advanced Features):
space + sn-> Move to the next misspelled word.space + sp-> Move to the previous misspelled word.space + sa-> Add the word under the cursor to the spell file.space + sw-> Mark the word under the cursor as a spelling mistake.space + ss-> Show spelling suggestions for the word under the cursor.
-
Competitive Programming Keybindings:
- Compile and Run:
space + c-> Compiles the current file (C++, Java). Python is interpreted, so it will just show a message.space + r-> Runs the compiled/interpreted program in a new terminal window.space + cr-> Compiles (if applicable) and then runs the program.
- Test Case Handling:
space + ti-> Creates an emptyinput.txtfile in the current directory.space + te-> Creates an emptyexpected_output.txtfile in the current directory.space + td-> Runs your program withinput.txtas stdin, saves the output tooutput.txt, and opens a diff view withexpected_output.txt.
- Compile and Run:
This configuration has been enhanced with several advanced features inspired by Vim's default settings and optimized for competitive programming.
-
Matchit Plugin: The
matchitplugin is now included. This plugin enhances the%command to jump between matching HTML/XML tags, and other language constructs. See the "Filetype Specific Features" section for more details. -
New Keybindings:
Q-> In normal mode, this key is now mapped togqfor easy text formatting. For example,gqapwill format the current paragraph.Ctrl-Uin Insert Mode -> This key combination is now undoable in a single step, making it safer to use.
-
New Options:
- Backup Files: Vim will now automatically create a backup file when you save a file. This can be useful for recovering lost work.
- Jump to Last Cursor Position: When you open a file, the cursor will automatically jump to the last known position.
-
Man Page Viewer: You can now use Vim to read man pages. Just run
man <command>in your shell, and it will open in Vim. -
Convert to HTML: You can convert the current buffer to an HTML file with the
:TOhtmlcommand. This is great for sharing code with syntax highlighting. -
Spell Checking:
- To enable spell checking, uncomment the
set spellandset spelllang=en_uslines inoptions.vim. - Once enabled, you can use the following keybindings:
space + sn: Move to the next misspelled word.space + sp: Move to the previous misspelled word.space + sa: Add the word under the cursor to the spell file.space + sw: Mark the word under the cursor as a spelling mistake.space + ss: Show spelling suggestions for the word under the cursor.
- To enable spell checking, uncomment the
-
Code Templates for Competitive Programming:
- Templates are available for C++ (
.cpp), Python (.py), Java (.java), C (.c), Golang (.go), Rust (.rs), and Bash (.sh). - To use, simply create a new file with the corresponding extension (e.g.,
:e main.cppor:e script.sh). The template will be automatically inserted.
- Templates are available for C++ (
-
Compile and Run (
space + c,space + r,space + cr):- These keybindings are available in normal mode.
space + c: Compiles the current file (C++, Java). For Python, it will just show a message as Python is interpreted.space + r: Runs the compiled/interpreted program in a new terminal window.space + cr: Compiles (if applicable) and then runs the program.
-
Test Case Handling (
space + ti,space + te,space + td):- These keybindings are available in normal mode.
space + ti: Creates an emptyinput.txtfile in the current directory for providing custom test inputs. Open this file to input your test data.space + te: Creates an emptyexpected_output.txtfile for storing the expected output of a test case. Open this file to paste or type the correct output.space + td: Runs your program withinput.txtas stdin, saves the output tooutput.txt, and then opens a diff view betweenoutput.txtandexpected_output.txt. This allows you to quickly compare your program's output with the expected output.
-
Debugging with
termdebug:- Vim's built-in terminal debugger is now enabled.
- To start a debugging session for a C/C++ program, compile your program with debugging symbols (e.g.,
g++ -g main.cpp -o main). Then, in Vim, use the command:Termdebug <your-program-executable>. This integratesgdbinto Vim, allowing you to set breakpoints, step through code, and inspect variables. Refer to:help termdebugfor more detailed usage.
-
Code Snippets with Abbreviations:
- You can create simple code snippets using Vim's built-in abbreviations. These are defined in your
keybinds.vim. - To use an abbreviation, type the abbreviation in insert mode, and it will expand automatically.
- Examples:
- C++:
forloopexpands to a basicforloop. - Golang:
mainf: Expands to a basicfunc main()structure.forr: Expands to afor ... rangeloop structure.
- Rust:
mainf: Expands to a basicfn main()structure.forr: Expands to afor ... inloop structure.
- Bash:
shbang: Expands to#!/bin/bashwith a newline.iff: Expands to a basicif [ ] then fiblock.
- C++:
- You can create simple code snippets using Vim's built-in abbreviations. These are defined in your
-
Autosuggestions:
- While Vim's core functionality is autocompletion (triggered by
Ctrl-NorCtrl-X Ctrl-O), true autosuggestion (suggestions appearing as you type) can be achieved with external plugins. If you wish to explore this, you might consider plugins likevim-autosuggestions(which you would install using Vim's native package management by cloning it into~/.vim/pack/plugins/start/).
- While Vim's core functionality is autocompletion (triggered by
This configuration uses Vim's filetype plugins to provide features tailored to specific programming languages. These plugins are enabled by filetype plugin indent on in options.vim, so you get all these features automatically.
- Omni Completion: Use
Ctrl-X Ctrl-Oin insert mode for intelligent completion of Python code. - Navigation:
]]and[[: Jump between classes and functions.]mand[m: Jump to the next/previous method.
- Documentation: Press
Kon a keyword to open its documentation withpydoc. - Testing: If you are in a file named
test_*.pyor*_test.py, you can runpyteston it with the:makecommand.
- Omni Completion: Use
Ctrl-X Ctrl-Oin insert mode for intelligent completion of C/C++ code. - Navigation: Use
%to jump between#if/#elif/#else/#endifblocks. - Documentation: Press
Kon a keyword to open its man page in a new terminal window.
- Omni Completion: Use
Ctrl-X Ctrl-Oin insert mode for intelligent completion of HTML tags. - Navigation: Use
%to jump between opening and closing HTML tags. - Folding: HTML tags will be automatically folded. You can use
zato toggle folds.
- Formatting: Use
gqto format your Go code withgofmt. For example,gqipwill format the current paragraph. - Navigation:
]]and[[: Jump betweenfuncandtypeblocks.
- Documentation: Press
Kon a keyword to look up its documentation withgo doc.
- Navigation: Use
%to jump betweenif/fi,for/done, andcase/esac. - Documentation: In a bash script, press
Kon a command to look up its documentation. - Linting: If you have
shellcheckinstalled, you can run it on your script with the:makecommand to find potential errors. You can install it withsudo apt install shellcheck,sudo dnf install shellcheck, orsudo pacman -S shellcheck.
shift + 5-> for new file in parent directory:e-> in vim :e is used for new file creating in a parents sub-dir.:so-> after making some changes in .vimrc this is the source command in vim.shift + v-> for seleceting multiple lines.y-> after selecting the things you can copy that in vim using that y keybind.y -> yan/copyp-> that stands for paste. after y you can paste that using **p.p ->> paste`shift + c-> this help to delete selected portion and directly get into insert mode.x-> in normal mode you can delete a single letter using it.dd-> it can delete a single line.m + <any_letter/number>-> This can help to mark a point in your code.w-> this is for go to one word by word jump forward.b-> this is for go to one word by one word jump in backward.- `/ -> this is for find anything.
n-> after find that is the next word jump keybind forward.N/ shift + n-> this is for reverse side jumpctrl + n-> show suggestion in your code after writing something where you forgot.ctrl + r-> for replace anything.esc-> that helps to go commander mode.i/a-> that help to go in insert mode. where you can able to write.:w-> when you write something then if you want to save that then hit esc then type that *:w to save.:q-> when you want to quite that save file then you have to enter that :q command (before you go every time you have to hit esc button):q!-> when you want to over write your code or something what you written and get back to your old code or thing then this is the helper for you.u(undo) -> when you are in commander mode then it will undo the thing what you did to that code.ctrl + r(redo) -> If you did something right and took wine and then do the wrong thing again then this is the helper for you.:colorscheme-> this help you to set colorscheme in your vim. (preinstalled only)
- When you are deleting one word you can give size like
7xthat will gonna delete 7 letters form your that line and the courser place Or for a worddw. - Similar for
ddyou can do it by entering any line number that will delete form your courser present place. like10dd-> 10 line delete.
To be continue........ :)