A blog dedicated to text editing and general exploration of computing knowledge
Monday, November 2, 2009
Knowing Where You Are
If you want to know the current filename, what percentage of the current file you're editing, whether the current file has been modified, or the character or line position, all you have to do is hit ctrl-g from normal mode inside Vim.
5 comments:
Anonymous
said...
I love these little tidbits -- please keep 'em coming!
If you think that info is useful and want to see it all the time, put this in your .vimrc (hopefully it will format well in these comments):
set laststatus=2 set statusline=%f\ \ %y\ \ %3.3m%4.4r%=%l\ /\ %L,\ %c\ \
Feel free to customize... key: %f - filename %y - file type %m - modified flag %l - line lumber of cursor %L - total number of lines %c - column number of cursor
See ':help statusline' for more options %r - read only
I have a script up on vim.org that can search backwards for the most recent function declaration to tell you what function you're editing in, and what line number it starts on. It catches most styles of function declarations in C, C++, Python, and Perl. I'm working on beefing up the regex to include Objective-C. Jave is a little bit tricky since function/method declarations are harder to find when they don't start at column 0...
5 comments:
I love these little tidbits -- please keep 'em coming!
g^g will also give you a word count.
If you think that info is useful and want to see it all the time, put this in your .vimrc (hopefully it will format well in these comments):
set laststatus=2
set statusline=%f\ \ %y\ \ %3.3m%4.4r%=%l\ /\ %L,\ %c\ \
Feel free to customize... key:
%f - filename
%y - file type
%m - modified flag
%l - line lumber of cursor
%L - total number of lines
%c - column number of cursor
See ':help statusline' for more options
%r - read only
I have a script up on vim.org that can search backwards for the most recent function declaration to tell you what function you're editing in, and what line number it starts on. It catches most styles of function declarations in C, C++, Python, and Perl. I'm working on beefing up the regex to include Objective-C. Jave is a little bit tricky since function/method declarations are harder to find when they don't start at column 0...
http://www.vim.org/scripts/script.php?script_id=1628
Dan, thanks a lot for your post. That's great to know where you are ;-)
Post a Comment