Showing posts with label VIM. Show all posts
Showing posts with label VIM. Show all posts

Thursday, March 12, 2015

[VIM] Move screen before cursor reaching top or bottom

It's interesting that I didn't realize I had been living without this feature for years as a vim user. Thanks to @tenderlove and @searls for publishing their vim setup session video. In the beginning of this video, @tenderlove adds set scrolloff=2 to vimrc. scrolloff is a good config that everyone who's using vim should have in their vimrc.

What it does is to tell vim to move screen before cursor reaching 2 top or bottom lines (2 is an arbitrary number). Give it a try. I bet you'll like it.

I went observe on JetBrains' IDE, they are configured to behave the same with setting scrolloff=1 on vim.

Friday, March 29, 2013

[Fixed][VIM] E354: Invalid register name: '*'

This error occurs when you or some of your vim plugins try to access register '*' which is a system clipboard. In default Mac OSX vim, it is compiled without system clipboard support enable. You can check this by run command :version inside vim. In the result, you will see -clipboard. Disable is -, enable is +.

To solve this issue, you need to compile vim with +clipboard yourself. I suggest OSX users to use brew to help this process. Out-of-the-box brew compiles vim with +clipboard. To do this run
brew install vim
Then you might need to create a new symbolic link from your vi command to point to the newly installed vim.
First you need to know the path of your new vim. Run
brew info vim
You should see something similar to /usr/local/Cellar/vim/7.3.875 in the result which means your vim binary file is at /usr/local/Cellar/vim/7.3.875/bin/vim. To create a new symbolic link for vi, first you need to remove the existing link
sudo rm /usr/bin/vi
Then you can create a new link.
sudo ln -s /usr/local/Cellar/vim/7.3.875/bin/vim /usr/bin/vi

Sunday, October 14, 2012

[VIM] + and * register don't work with clipboard on MacOSX

This problem is because VIM version that shipped with MacOSX doesn't enable xterm_clipboard. You can check this by run :version command in VIM. Enabled xterm_clipboard VIM must have +xterm_clipboard but the version shipped with MacOSX has -xterm_clipboard.
If you want it to be enabled, you need to compile VIM yourself with clipboard enabling flag.

Sunday, November 6, 2011

Saturday, September 17, 2011

Friday, September 9, 2011

Useful VIM command that I still can't remember



  • “0p - pastes the last explicitly copied text
  • :reg - Show a list of registers
  • J - Merge current line With Next Line
  • =, == - Fix indention
  • u,U(in visual mode) - lower, uppercase
  • q: - list command history
  • q/ - list search history
  • Ctrl ^ - go to previous buffer
  • :w !sudo tee % - save readonly file
  • diw - delete a word
  • di(, da( - delete text inside/include ()
  • di", da" - delete text inside/include ""
For rails.vim
  • gf - open file from cursor
  • :R{view,model,controller,spec} {file}

Tuesday, August 16, 2011

[VIM] Mostly use FuzzyFinder and NERDTree shortkeys

Basic VIM
- Open new horizontal split :sp file
- Open new vertical split :vs file
- Switch between split pane: Ctrl-w + { h|j|k|l }
- Rotate pane down/right: Ctrl-w + r
- For more, see Vim documentation: windows

FuzzyFinder
- Open in vertical split: Ctrl-k
- Open in horizontal split: Ctrl-j

NERDTree
- Open in vertical split: s

Monday, July 25, 2011

More advance commands for moving cursor and screen in VI

These are VI commands I have just learned today

F = reverse of f
t = f and step back 1 char
T = reverse of t
; = repeat f, F, t and T

H = Move cursor to first line of the screen
M = Move cursor to middle of the screen
L = Move cursor to last line of the screen

z. || zz = Move screen to make cursor to middle of the screen
zt = Move screen to make cursor to top of the screen
zb = Move screen to make cursor to bottom of the screen

Ctrl+f = Scroll down 1 screen (Ctrl+d only half screen)
Ctrl+b = reverse of Ctrl+f

Ctrl+e = Move screen down 1 line with the cursor try to stay at the sameline
Ctrl+y = reverse of Ctrl+y

Tuesday, June 21, 2011

Monday, May 10, 2010

VIM - How to format and syntax highlight JSON file

Formatting
  • Run this command in shell 
    sudo cpan JSON::XS
  • Put this line to ~/.vimrc 
    map <leader>jt <Esc>:%!json_xs -f json -t json-pretty<CR>
  • When want to format JSON file press
    \jt

  • credit : “tidify” a json in vim
Syntax highlighting

Friday, April 23, 2010

VIM - How to format Html source code

  1. :filetype indent on
  2. :set filetype=html
  3. :set shiftwidth=n (n = indent size)
  4. :set smartindent
  5. gg=G (gg = top of file, = is a shortcut of re-tindent, G = botton of file)

For 1,3,4 , you can predefine at .vimrc. While editing Html file, just do 2 and 5

VIM - How to format JavaScript source code

  1. Download this plugin jsbeautify
  2. Copy it to $HOME/.vim/plugin/
  3. In Vim, while you want to format JavaScript code, press \ff*
* From jsbeautify's document tells to press <leader>ff which in Vim <leader> by default is set to "\"

Saturday, December 20, 2008

VIM - tab size & tab to space setting

to change tab size use this command
:set ts=n
(n=expected size ,ts=tabstop)

to change tab to space use this command
:set et
(et = expandtab)

also invoke it together like this
:set ts=4 et

if you want permanent changing, add command above to file named .vimrc (normally is at your home folder)

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...