Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's left of Vimscript?


May 25, 2021 Vim


Table of contents


If you've read here and completed all the examples and exercises, you're now solid at the Vimscript foundation. Don't worry, there's a lot more to learn!

If you're thirsty for knowledge, there's something to explore.

Color scheme

In this book we added syntax highlighting to the Potion file. As the other side of the coin, we can also create a color scheme to determine the color of each syntax element.

Making Vim's color scheme is very simple and straightforward, even a bit repetitive. R ead :help highlgiht to learn the basics. You may want to look at some of the built-in color schemes to see how they organize their files.

If you're eager to challenge, check out my own Grey Wolf color scheme to see how I use Vimscript to simplify definition and maintenance for me. Note the "palette" dictionary and HL functions, which dynamically generate highlight

Command command

Many plug-ins allow users to interact with key maps and function calls, but some prefer to use Ex commands. For example, fugitive plug-ins create things :Gbrowse and : :Gdiff the way they are called to the user for customization.

Commands like this are :command command command. R ead :help user-commands learn how to make one for yourself. You should have learned enough Vimscript to help you understand the Vim documentation and use it to learn new commands.

The run-time path

In this book, when it's about how Vim loads a file, I use "Pathogen" to deal with the past. Now that you know a lot about Vimscript, you :help runtimepath check pathogen source code to find out what's hidden behind the scenes.

Omnicomplete

Vim provides many different ways to complete the text :help ins-completion Most are simple, but the most powerful of them is "omnicomplete", which allows you to call a custom Vimscript function to determine the various ways you want to make up.

When you decide to take a look at omnicomplete, you can start your journey by starting with :help omnifunc :help coml-omni

Compiler support

In our Potion plug-in, we created some mappings to compile and execute Potion files. Vim provides more in-depth support for interacting with the compiler, including parsing compiler errors and generating a neat list for you to jump to the corresponding errors.

If you're interested in this, you can start by reading through the entire :help quickfix.txt the whole story. However, I have to remind you that errorformat suitable for people with weak hearts to read.

Other languages

The book focuses on Vimscript, but Vim also provides interfaces in other languages, such as Python, Ruby, and Lua. This means that if you don't like Vimscript, you can expand Vim in other languages.

Of course, you still need to understand Vimscript to edit ~/.vimrc and understand the APIs Vim provides to other languages. But using an alternative language may be a good way to free you from the limitations of Vimscript, especially when writing large plug-ins.

If you want to learn more about expanding Vim in a specific language, check out the following corresponding help documentation:

  • :help Python
  • :help Ruby
  • :help Lua
  • :help perl-using
  • :help MzScheme

Vim documentation

As a final section, here are some Vim help entries that are useful, interesting, reasonable, or just fun (ranked in no order):

  • :help various-motions
  • :help sign-support
  • :help virtualedit
  • :help map-alt-keys
  • :help error-messages
  • :help development
  • :help tips
  • :help 24.8
  • :help 24.9
  • :help usr_12.txt
  • :help usr_26.txt
  • :help usr_32.txt
  • :help usr_42.txt

Practice

Write a Vim plug-in for the features you want and share your results with the world!