How to add a command in vim editor?
Problem
If suppose my source code file name is "foo.c". While editing and debugging i always execute this command:- :!gcc -g foo.c -o foo;gdb foo Can I add a custom command to Vim such that If i type ":debug" then the above command executes? How do I achieve that?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How to add a command in vim editor?
Yes. Vim documentation, section 40.2, Command-line mappings: The Vim editor enables you to define your own commands. You execute these commands just like any other Command-line mode command. To define a command, use the ":command" command, as follows: :command DeleteFirst 1delete Now when you execute the command ":DeleteFirst" Vim executes ":1delete", which deletes the first line. Note: User-defined commands must start with a capital letter. You cannot use ":X", ":Next" and ":Print". The unders…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix