Archive

Archive for the ‘vim’ Category

ALE (Asynchronous Lint Engine)

December 4, 2018 Leave a comment

ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim 0.2.0+ and Vim 8 while you edit your text files, and acts as a Vim Language Server Protocol client.

ALE makes use of NeoVim and Vim 8 job control functions and timers to run linters on the contents of text buffers and return errors as text is changed in Vim. This allows for displaying warnings and errors in files being edited in Vim before files have been saved back to a filesystem.

In other words, this plugin allows you to lint while you type.

https://github.com/w0rp/ale

Advertisements
Categories: vim Tags: ,

Trying out code completion in vim

November 3, 2018 Leave a comment

Trying out code completion in vim. Installed `Youcompleteme`.

Steps:
1. The version of vim on macosx that I had did not have +python3 or +conceal that was needed with some of the completion engines that were installed.

# To check if vim has the needed versions
$ vim --version
+python3 # Supported
-python3 # Not supported

2. Install macvim

$ brew install macvim

Create an alias (Save this to .bashrc or .zshrc)

alias vim='mvim -v'

3. Install cmake

$ brew install cmake

4. Download YouCompleteMe and install using Pathogen

$ cd ~.vim/bundle
$ git clone https://github.com/Valloric/YouCompleteMe.git
$ git submodule update --init --recursive
$ cd YouCompleteMe
$ ./install.py --all

5. Edit some code

Source:
https://github.com/Valloric/YouCompleteMe
http://liuchengxu.org/posts/use-vim-as-a-python-ide/

Categories: vim Tags:

Different tabs for different files

September 14, 2018 Leave a comment

Problem:

Needed to have different tabs for different files when editing with vim. Eg in python tab == 4 spaces, in a MakeFile tab == tab.

Solution:

Added this to ~/.vimrc

" Use different indentation for yaml files
 autocmd FileType yaml,yml setlocal tabstop=2 expandtab shiftwidth=2 softtabstop=2

 " In makefiles, don't expand tabs to spaces, since actual tab characters are
 " needed, and have indentation at 8 chars to be sure that all indents are tabs
 autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0

Source:
https://superuser.com/questions/632657/how-to-setup-vim-to-edit-both-makefile-and-normal-code-files
https://github.com/spf13/spf13-vim/issues/789#issuecomment-118369177

Categories: vim Tags:

Clear highlighting on escape in normal mode

December 22, 2016 Leave a comment

Problem:
How to disable highlighted text after doing a search in vim?

Solution:
Added the following to my .vimrc

 " Clear highlighting on escape in normal mode
 nnoremap <esc> :nohlsearch<return><esc>
 nnoremap <esc>^[ <esc>^[

System details:
vagrant box running ubuntu/trusty64

Source:
http://stackoverflow.com/questions/657447/vim-clear-last-search-highlighting?rq=1

Categories: vim Tags: ,

Custom Colors

December 21, 2016 Leave a comment

Problem:
I had set up my vim to run flake8 when I save python files. The issue now was that the quickfix window would display the errors in white/white-grey text on a yellow background. That proved to be really hard to read.

white on yellow

Solution:
1. One option was to change my colorscheme to something that would display the text. (Many hours later I still had not found a colorscheme that I liked.)
2. Change the color for just that “aspect”.

So I went with option 2 and changed the color. Which resulted in black on yellow and is now much easier to read.
screen-shot-2016-12-21-at-22-13-58

Steps:
While in vim look at the current colors that are already set. (:highlight or :hi)

:highlight

highlight

The colors I wanted to change were for ‘Search’. So while still in vim

:highlight Search term=reverse ctermbg=11 ctermfg=0  guibg=Yellow

To make this permanent I added the following to .vimrc

highlight clear
highlight Search term=reverse ctermbg=11 ctermfg=0  guibg=Yellow

Source:
http://andrewradev.com/2011/08/06/making-vim-pretty-with-custom-colors/
http://superuser.com/questions/654919/how-to-turn-off-gvim-error-highlighting

Categories: vim Tags:

QuickFix

December 21, 2016 Leave a comment

quickfix-window

QuickFix is designed to display compiler errors — a list of errors is displayed and can be selected to jump to a specific file and line.

:cn — Go to the next location in the list
:cp — Go to the previous location
:ccl — Close the quickfix window

Depending on where your quickfix window is. You can use below keys to move in and out of the window. (If quickfix window is at the bottom part of your screen)
CTRL-w + j — Move into the quickfix window
CTRL-w + k — Move out of the quickfix window

The window commands will work here. See link in source section below for more details.

Source:
http://usevim.com/2012/08/24/vim101-quickfix/
http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
http://vimdoc.sourceforge.net/htmldoc/windows.html#windows

Categories: python, vim Tags:

Tab navigation

December 20, 2016 Leave a comment

In normal mode, you can type:

gt go to next tab
gT go to previous tab
{i}gt go to tab in position i

Note that the gt command counts from one. That means 3gt will jump to the third tab. Also note is 0gt and 1gt mean the same thing: jumping to the first tab.

http://vim.wikia.com/wiki/Using_tab_pages

Categories: vim Tags: ,