Tag Info

Hot answers tagged

34

From this stackoverflow answer, by skinp :w !sudo tee % I often forget to sudo before editing a file I don't have write permissions on. When I come to save that file and get a permission error, I just issue that vim command in order to save the file without the need to save it to a temp file and then copy it back again.


17

First, if you have more than a couple machines you work with, consider putting your ~/.vim/, ~/.vimrc and other useful config files (screen, your shell, etc.) in a revision control system. I prefer using darcs - it's cheap on Debian systems (no need to install Haskell compiler, just install the package directly), distributed, and has great interactive modes. ...


15

I just found one way to do it: if has("gui_macvim") " set macvim specific stuff endif


13

You want to set option scrolloff: 'scrolloff' 'so' number (default 0) number of screen lines to keep above and below the cursor. This will make some context visible around where you are working. Use e.g. :set scrolloff=10 to always keep at least 10 lines visible.


13

Please do not vote me down for this. I do not recommend implementing this answer, but it is the answer that the rkthkr is asking for. rkthkr said: But it would be nice to have vim restarted and run as root The way to do this is with :!sudo vim % As I mentioned to ipozgaj, a % as an argument (even a sub-argument) gets replaced with the path to the ...


6

Not really sure what part of this is specifically sysadmin related, but my essentials are: syntax on set background=dark set shiftwidth=2 set tabstop=2 if has("autocmd") filetype plugin indent on endif set showcmd " Show (partial) command in status line. set showmatch " Show matching brackets. set ignorecase " Do case ...


4

From the help in vim for CTRL-V-alternative: Since CTRL-V is used to paste, you can't use it to start a blockwise Visual selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q doesn't work for terminals when it's used for control flow. These lines are ...


4

Our CTO has a pretty feature-filled Vim configuration on GitHub. Highlights: Syntax highlighting, 2 space tabstop, expanded tabs. NERDtree, a file-tree view similar to TextMate's project drawer. FuzzyFileFinder, plugin to do TextMate's cmd-T functionality. Lots of color themes with a nice one (twilight) default. I find it great for Ruby coding, as our ...


4

If you are usually working at a user, than this make it possible to "pipe" a file to sudo so it can be saved. cmap w!! %!sudo tee > /dev/null % use the command: :w!! to envoke sudo and save the file.


4

$ vimtutor for starters. I remember Emacs has a tutorial of some sort from back when I was choosing an editor, but I don't remember what it is. I'd say learn enough about both to be able to function, then pick one or the other and master it (as much as possible--I'm finding after 7 years of using Vim that there's always lots to learn).


4

In order to make it permanent, you should add that to your ~/.vimrc file. That's a personal vimrc, as opposed to the system wide one that you're probably looking at. The syntax is slightly different, so what you would do is add the line colors desert to your local config file, again that's ~/.vimrc and you're good to go.


3

When in screen, just do "C-a a" instead of just "C-a" ie Hit "Control-a" then type "a" again. The number under the cursor will increment!


3

From man screen: -e xy specifies the command character to be x and the character generating a literal command character to y (when typed after the command character). The default is "C-a" and `a', which can be specified as "-e^Aa". When creating a screen session, this option sets the default ...


3

You can also look at this SO question: What's in your vimrc?


2

Shameless plug. This is not really a .vimrc change but rather a VIM plugin. I use RCSVers on every installed version of VIM. Basically it uses the RCS command to save off a version of any file you edit. You don't know how many times I've screwed up a config file only to have RCSVers save me by showing me the changes I've made. ...


2

Don't use .vimrc to avoid learning VIM Since I know that a lot of VIM new comers will read this, the best suggestion I have is: "Do not get lazy and put map entries in your .vimrc" Learning non-standard ways of doing things in VIM will make you feel like a total gimp when you are without your vimrc. The learning curve for vi is steep, but you are not doing ...


2

Make sure the locale is installed on the system (debian/ubuntu: aptitude install locale) On the shell: setenv LANG In vim: :language In vim: :set encoding=utf-8 Try again and tell me if it works I also found this while googling: http://raviratlami1.blogspot.com/2007/04/how-to-write-hindi-in-linux.html and thats the vim docu: ...


2

This is an old question but I thought I'd add my suggestions in case any one else has similar issues and they aren't in a position to come up with a better solution: For Vim, a simplistic solution would be to run: vim -u /my/personal/repos/dotfiles/.vimrc But that will use the account's .vim / vimfiles directory structure. If the server is some form of ...


2

vimtutor is an excellent tutorial for you to go through. Also the built-in help in vim is very nice. Use :help inside vim for explanation about practically anything related to vim. And of course there's Vigor, a User Friendly cartoon turned into reality. :-)


1

like what martian said. the syntax file should live under ~/.vim/syntax/todo.vim the plugin file should live under ~/.vim/filetype.vim setting those will probably resolve your issue with detection, since the syntax in your filetype.vim seems correct. what might be a funny issue is to have problems due to writing setfiletype todo instead of ...


1

The syntax file should live in ~/.vim/syntax, that's all.


1

In addition to the points listed by frisbee23, you should also make sure that you're using a UTF8-capable terminal (gnome-terminal, konsole, urxvt, etc), and that the terminal font you've selected supports displaying Hindi characters.


1

It's easier to get to the bottom of a file with shift-g. It does not go past the end of the file.


1

The best thing I've learned recently is using jj instead of <esc> to enter normal mode: imap jj <Esc> Also, if you make use of splits via the split (tall terminal) or vsplit (wide terminal) command, then remapping the switch-split command is invaluable; I use , (comma) to switch amongst my splits: map , <C-w><C-w> Check out the ...


1

I usually save it to a temporary file in $HOME/tmp/apache.conf (for example) then sudo vimdiff $HOME/tmp/apache.conf /etc/apache2/apache.conf this is some extra work to merge the changes but it paid off. I find it to be a nice way between convenience and measurements against unwanted changes Before that I was thinking of ACLs or assigning corresponding ...



Only top voted, non community-wiki answers of a minimum length are eligible