GithubHelp home page GithubHelp logo

minivim's Introduction

MiniVim

Click to launch a YouTube video demo:

A screenshot

A longer and more up to date demo is available here : Demo

Goals

  • Mimic Sublime Text / Shell key mappings
  • Minimal: one file, no plugin needed!

Automated setup

  • Clone this repo to the folder of your choice:

git clone https://github.com/sd65/MiniVim.git

  • Go inside this repo:

cd MiniVim

  • Launch the install script and follow the instructions:

./install.sh

  • It's ready! 😄 Launch Vim:

vim

Manual setup

If you can't clone the repo and do the above steps, just download the .vimrc to your home dir (backup your current .vimrc before).

wget https://raw.githubusercontent.com/sd65/MiniVim/master/vimrc -O ~/.vimrc

And then add stty -ixon to your .zshrc or .bashrc (your shell will ignore XON/XOFF signals. Needed to remap Ctrl S, Ctrl Q). It will prevent the terminal from "freezing" when saving a file or duplicating a line.

How to use

  • The key mappings can be used in Insert, Normal and Visual mode (yes, no need to exit Insert or Visual mode)
  • The mouse can be used in Normal and Visual mode to scroll, select, change tab and more.
  • There are clear visual hints on which mode you currently using. Like pink=normal, blue=insert and green=visual...

General Mappings

You hate those mappings? No problem, change this in your .vimrc : UseCustomKeyBindings=0.

Keys Action Comments
Moving ---------- ----------
Arrows Move the cursor Like every editor
Ctrl Arrows Move the cursor fast. Ctrl is a booster!
Ctrl A Go to the beginning of the line As in Nano/Shell
Ctrl E Go to the end of the line As in Nano/Shell, remember as End
Home Go to the beginning of the file Self explanatory
End Go to the end of the file Self explanatory too
Tabs ---------- ----------
Ctrl T Open a new tab Like Sublime, remember as Tab
Alt Arrows Switch between tabs. Ctrl Tab cannot be mapped...
History ---------- ----------
Ctrl Z Undo Like Sublime
Ctrl R Redo Like no other, remember as Redo
Editing ---------- ----------
Tab Indent Like Sublime
Shift Tab Unindent Like Sublime
Ctrl F Find Like Sublime, remember as FInd
Ctrl H Search and Replace Like Sublime
Ctrl G Search and Replace on the line Useful when duplicating a line and editing the new one
PageUp Move the line up Usefull function so dedicated key (don't trust me ? Try it.) Ctrl is a booster too!
PageDown Move the line down Same as above
Ctrl K Delete the whole line/block Like in nano, inspired by Sublime too, remember as Kill the line
Ctrl Q Duplicate the line/block Remember as "dupliqate"?
Ctrl L Clear/Delete all lines Like in a shell, remember as Clear
Ctrl D Delete char from the left, as Del Like in a shell, remember as Delete
Ctrl N Autocomplete word Default VIM mapping but interesting one
Ctrl \ Comment/Uncomment Depends on filetype
Vital ---------- ----------
Ctrl S Save Like Sublime, remember as Save
Ctrl C Quit Like in a shell
Miscellaneous ---------- ----------
F2 Set paste toggle With paste on you can paste more easily
F3 Show line numbers toggle Show or hide line numbers
F4 Panic Button! Toggle garbage screen Remember as "I need to alt-F4!"
F6 Toggle color column at 80th char A visual helper to write clean code

Mappings in Explorer

Keys Action Comments
Ctrl O Open the Explorer Remember as Open
Enter or Right Arrow Enter a file/dir Easy one
Left Arrow Go up a dir Easy one too
l Display info on file/dir Remember as ls
n Open a menu to make an action (Create file/dir, Rename, Delete) Remember as ... New action?
a Toggle 'Show Hidden files only, Show All, Hide hidden files (default)' Default mapping
Ctrl C Quit Like in a shell

Custom commands

You can enter those command in normal mode.

Cmd Action
:UndoCloseTab Reopen the last close buffer/tab in a new tab
:RemoveTrailingSpaces Remove the unwanted spaces at the end of lines

How to add plugins to MiniVim

The automated setup source in the main Vim configuration file (.vimrc) MiniVim. This means that you have a clean and standard .vimrc.

To keep MiniVim, don't delete the source [...]/MiniVim instruction in the .vimrc file.

To add plugins, simply follow the plugin's instructions. You should manage them with a plugin manager as Vundle or the old Pathogen.

How to use MiniVim with sudo

First, you could install MiniVim as root. Or better soft link your .vimrc. But it's sometimes not the best solution, like in a company where the root user is shared.

So, you can configure your system to use MiniVim when you sudo vim [file]. There are 2 solutions :

  • sudo -E vim [file] as -E preserve your existing environment variables (as $HOME here and therefore your ~/.vimrc).
  • sudoedit [file] or sudo -e [file] (synonyms). To use this, you must have set your $EDITOR environment variable. Then, this command will make a copy of the designated file and you will edit the copy. Note that the original file will only be modified when you exit your editor !

How to update MiniVim ?

First, you have to fetch the latest MiniVim. If you had cloned the repo, simply git pull. Else, re-download the lastest version on GitHub.

If you setup MiniVim automatically, simply re-run the installer. It will take care of everything.

If not, copy again the vimrc file to ~/.vimrc

Other info

The file is heavily commented. You're welcome to open, read and change what you want. It's easy.

  • Work with Vim and GVim.
  • Please keep in mind that some keys cannot be mapped as Ctrl Shift Something or Ctrl Tab because of Terminals limitations. I have to compose with this 😕 If you're on Windows with Putty or similar, you may experience problems because of key codes. Look at this tip for PuTTY numeric keypad problems and this one for other mappings that doesn't work.
  • The color scheme is based on https://github.com/sickill/vim-monokai.
  • Smart Paste system is based on https://github.com/ConradIrwin/vim-bracketed-paste.
  • In the bottom right-hand corner, you have numbers 115/142(90%)-10. Line 115, total lines 142, position at 90% in the file and column 10.
  • Tabulations will be expanded into two spaces, the default indent size.
  • UTF-8 by default.
  • Backups and Swapfiles are stored in $HOME/.vim/.
  • Pressing Enter, Space or Backspace in normal mode will enter insert mode and do action.
  • When re-opening a file, Vim will remember the last position.
  • When opening multiple file (as vim file1 file2), Vim will open those files in new tabs automatically.

Changelog

1.5.1

  • Fix a bug where the terminal back buffer was mangled after exiting Vim

1.5

  • Change the terminal title to the current edited file
  • Faster color mode changes

1.4

  • Comment & Uncomment feature
  • Improve block move Up/Down
  • Minor bug fixes

1.3.3

  • Smart paste
  • The default mode is "Normal"

1.3.2

  • Configuration is kept in .vimrc to persist between updates
  • Better README

1.3.1

1.3

  • Custom save function
  • Complete words containing a dash
  • Replace on the line
  • Better cursor position after duplicating a block
  • Added percentage in statusline
  • Added the 'Remove Trailing Spaces' function
  • Small fixes and typos fixed

1.2

  • Fix the visual block mode
  • Fix the incremental search
  • Install.sh is now POSIX
  • Fixed typos

1.1

  • Better code organisation
  • Toggle custom key bindings easily
  • Toggle 80th column char
  • Open file browser in new tab only if tab is empty
  • Fix typos

1.0

Initial release.

minivim's People

Contributors

etiennem avatar kaspermeerts avatar rgaudin avatar ryanoasis avatar sd65 avatar wes974 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minivim's Issues

Ctrl H - Backspace

Hi,

"Ctrl H - Search and Replace
call CreateShortcut("C-h", ":%s/", "in", "noTrailingIInInsert")`

Traditionally, CTRL-H is for "backspace key" and deletes the character that is left of the cursor.
That does not seem to me convenient to use to search .

Source personnal config

It could be nice if we could add customization in another file, with something like:

try
source ~/.vim/my_configs.vim
catch
endtry

at the end of the .vimrc

new feacture - Paste

Hi,
Do there are a way to paste with ctrl-V, when a read the conf, I suppose it's not difficult, but can you add :set paste and :set nopaste before and after the paste to remove indent because code i lot of the time already indent

Thank
(your work is awesome)

Performance: statusline causes lag

Here is how to reproduce:

Download and edit the miniconda https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh

Scrolling to the binary area, around line 450, and vim will be very lag.

Imgur

As a vim developer pointed out, the statusline invokes pretty often.

The workaround is using a cache function.

@@ -781,6 +781,14 @@ let colorsAndModesGui= {
   \ 'V' : '#ffff00',
   \ '^V' : '#ff8700',
 \}
+function! LastAccentColor()
+  if !exists('b:lastMode') | let b:lastMode = mode() | call ChangeAccentColor() | endif
+  if b:lastMode != mode()
+    let b:lastMode = mode()
+    call ChangeAccentColor()
+  endif
+  return ''
+endfunction
 function! ChangeAccentColor()
   let accentColor=get(g:colorsAndModes, mode(), g:defaultAccentColor)
   let accentColorGui=get(g:colorsAndModesGui, mode(), g:defaultAccentColorGui)
@@ -864,7 +872,7 @@ let g:currentmode={
     \ 't'  : 'Terminal',
 \}
 set statusline=
-set statusline+=%{ChangeAccentColor()}
+set statusline+=%{LastAccentColor()}
 set statusline+=%1*\ ***%{toupper(g:currentmode[mode()])}***\  " Current mode
@@ -882,7 +882,7 @@ set statusline+=%2*\ [%{&filetype}] " Filetype
 set statusline+=%2*\ %{ReadOnly()} " ReadOnly Flags
 set statusline+=%1*\ \%l/%L(%P)-%c\  " Position
 " Speed up the redraw
-au InsertLeave * call ChangeAccentColor()
+" au InsertLeave * call ChangeAccentColor()

MiniVim and tmux problem

Hi,

I'm having trouble having some of MiniVim shortcuts to work with a vanilla tmux.
For instance, changing tabs shortcut Alt-Right/Left doesn't work at all.

I've tried setting up in tmux with:
set-option -g xterm-keys on
In order to send the right key combinations to the terminal emulator, but in that case that's even worse, Alt-Right/Left cuts lines in a pattern I still have to understand.

I've also tried different terminal emulator variants like screen, xterm or there 256 colors versions, but it doesn't change anything to my problem.

Thanks.

[Resolved] Issue with file saving

Hi,

When I press Ctrl + S vim (in MiniVim mode) doesn't save my file nor displaying something : it does nothing. I'm doing anything wrong or is it not working ?

Tchaly

Color

Hi, how to change color with minivim?
Cause colors aren't well done.
I can't see comment in my file cause they're in dark color.

Extremely slow typing when editing git commit

Hi,

I noticed that when I do a git commit and vim opens to write the commit, typing is really slow and laggy.
And the more there is information to show in the commit (the list of files that will be committed, the list of file ignored, etc), the more it slow and laggy!

It's really stange!

Public key issue with automated setup

Hello!

I tried to install miniVim with the automated setup, but it returned this error:

Cloning into 'MiniVim'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Any idea why?
Meanwhile I’ll try the manual setup…

Thanks for sharing this with the world! ;)
.V

More convenient OS pasting

Hi,

I'm having a strange behaviour when pasting lines with multiple leading tabs :

[_]stuff 1
[_]stuff 2
[_]stuff 3

# paste it :

[_]stuff 1
[_]stuff 2
[_]stuff 3

but

[_][_]stuff 1
[_][_]stuff 2
[_][_]stuff 3

# paste it :

[_][_]stuff 1
[_][_][_][_]stuff 2
[_][_][_][_][_][_]stuff 3

How could I prevent that?
Awesome job by the way, I put it on every laptop/VM...

minivi.ml domain for the project.

I’m currently owning minivi.ml, and it’s set up to redirect to your Github page.

If you want to manage it yourself, drop me an email (everything here), and I will give it to you @sd65. However, since I couldn’t find the way to transfer it (actualy, it seems impossible for free domains), I would cancel it at a given time, with you ready to take it asap.

Document how to add plugins in a MiniVim relevant way

I know the objective of MiniVim is not to use plugins, but it can be useful sometime to be able to do it, preferably with a plugin manager that combines well with Minivim.

I'm not a vim expert so I'm not even sure how to do that, so I thought maybe we could document it on the main page of minivim :)

Fuzzy file search

First of all, great job ! It looks and feels great.
An option I really like and use with Sublime is the Ctrl+P option that let's you do a fuzzy search in the current directory (when you start it with subl .). Do you think it would be implementable ?

Status line & Block mode

Hello,

Really good job.
It seems like there is an issue with V-Block mode and status bar color update.
When I press CTRL + v I have the following message :

# french
E716: La clé ^V n'existe pas dans le Dictionnaire
E116: Arguments invalides pour la fonction toupper(g:currentmode[mode()])

# english
E716: ^V Key not present in Dictionary: 
E116: Invalid arguments for function toupper(g:currentmode[mode()])

The key seems to be present in vimrc : https://github.com/sd65/MiniVim/blob/master/vimrc#L324
Don't know if it's a bug or something else.

 $ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:03)
Rustines incluses : 1-488, 57

Trigger Ctrl N if there is no letter before cursor

I would like to show autocomplete popup everytime I try to input a word,
just like sublime text does.

So the purpose is:

  • set completeopt=menuone,noinsert,noselect,longest
  • If there is no letter before the cursor, trigger Ctrl N after I input the letter.
  • If there is already a letter before the cursor, just input the letter.
""" Just popup, never try to insert a word
set completeopt=menuone,noinsert,noselect,longest
imap a a<c-n>
imap b b<c-n>
imap c c<c-n>
imap d d<c-n>
imap e e<c-n>
imap f f<c-n>
imap g g<c-n>
imap h h<c-n>
imap i i<c-n>
imap j j<c-n>
imap k k<c-n>
imap l l<c-n>
imap m m<c-n>
imap n n<c-n>
imap o o<c-n>
imap p p<c-n>
imap q q<c-n>
imap r r<c-n>
imap s s<c-n>
imap t t<c-n>
imap u u<c-n>
imap v v<c-n>
imap w w<c-n>
imap x x<c-n>
imap y y<c-n>
imap z z<c-n>

function! GetCharBeforeCursor()
  if (getline(".")[col(".")-1] =~ '[a-z]')
      echo "There is a letter before cursor"
  else
      echo "No letter before cursor"
  endif
endfunction

I think I am so close, but I don't know what to do next.
Sorry, I should've done it myself but I am not familiar with vimrc.

I can't save in sudo

Hello, something really strange happened when I'm in sudo.
When I type Ctrl + S, vim just freeze and do I can't do nothing in vim... It's really disturbing and I don't know what to do

Mode visual bloc editing

Good morning,

I'm trying to use mode visual bloc, i put the shortcut on other keyboard shortcut but it's doesn't work.

Visual bloc mode is used, but i can't use the shortcut I{number} - ESC for multiple edit lines.

Thank's for help

Little issue with the number version

Hi,

First, great work for what you have done !
But there is a little issue that I get when I launch vim (I'm on a Mac with OS X 10.11.3)
When I launch vim I got this :

capture d ecran 2016-03-19 a 00 50 50

It's seems that there is a little issue with the number version. It's not a very important issue, I just press enter, but I thought thats I should tell you. For now I just correct it by changing the number version to 1. But otherwise, everything works great, thank you !

Simplify the addition of custom configuration

Since most user clone the minivim repository, when they want to add their own custom configuration (either tweaking the minivim configuration or separate things), they need to modify the version controlled file.

It would be great if minivim by default would recognize an extra file (and ignore if it isn't present) where to put such custom configuration.

Maybe it would be best if it was in the .vim/ directory, not sure :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.